excel userform列出变量而不是添加

时间:2017-10-14 04:18:06

标签: excel excel-vba vba

Private Sub UserForm_Activate()
  MultiPage1.Value = 0
End Sub

Private Sub Cmbo_A_Change()    
    If Cmbo_A = "Clay" Then
        TextBox1 = 20
    ElseIf Cmbo_A = "Sand" Then
        TextBox1 = 35
    Else
        TextBox1 = 35
    End If

    If Cmbo_A = "Clay" Then
        TextBox2 = 18
    ElseIf Cmbo_A = "Sand" Then
        TextBox2 = 16
    Else
        TextBox2 = 19
    End If    
End Sub

Private Sub Cmbo_P_Change()    
    If Cmbo_P = "Clay" Then
        TextBox70 = 20
    ElseIf Cmbo_P = "Sand" Then
        TextBox70 = 35
    Else
        TextBox70 = 35
    End If

    If Cmbo_P = "Clay" Then
        TextBox69 = "18"
    ElseIf Cmbo_P = "Sand" Then
        TextBox69 = 16
    Else
        TextBox69 = 19
    End If
End Sub

Private Sub Cmbo_W_Change()
    If Cmbo_W = "Clay" Then
        TextBox15 = 18
    ElseIf Cmbo_W = "Sand" Then
        TextBox15 = 16
    ElseIf Cmbo_W = "Concrete" Then
        TextBox15 = 23
    Else
        TextBox15 = 20
    End If
End Sub

Private Sub CommandButton3_Click()
    MultiPage1.Value = 1

    Pi = 4 * Atn(1)
    i = TextBox1.Value * (Pi / 180)

    q = TextBox70.Value * (Pi / 180)

    Dim hw As Double
    hw = TextBox5.Value
    Dim tw As Double
    tw = TextBox6.Value
    Dim h1 As Double
    h1 = TextBox7.Value
    Dim h2 As Double
    h2 = TextBox8.Value
    Dim bp As Double
    bp = TextBox9.Value
    Dim bw As Double
    bw = TextBox10.Value
    Dim ba As Double
    ba = TextBox11.Value

    TextBox30.Value = hw * bw
    TextBox31.Value = TextBox30.Value * TextBox15.Value
    TextBox32.Value = bp + (bw / 2)
    TextBox33.Value = TextBox32.Value * TextBox31.Value

    TextBox38.Value = tw * (bp + bw + ba)
    TextBox39.Value = TextBox38.Value * TextBox15.Value
    TextBox40.Value = (bp + ba + bw) / 2
    TextBox41.Value = TextBox40.Value * TextBox39.Value

    TextBox34.Value = hw * bw
    TextBox35.Value = TextBox34.Value * TextBox2.Value
    TextBox36.Value = bp + bw + (ba / 2)
    TextBox37.Value = TextBox36.Value * TextBox35.Value

    TextBox42.Value = (h2 - tw) * bp
    TextBox43.Value = TextBox42.Value * TextBox69.Value
    TextBox44.Value = bp / 2
    TextBox45.Value = TextBox44.Value * TextBox43.Value

    TextBox17.Value = Application.Round(Tan(Pi / 4 - (TextBox1.Value * (Pi / 180) / 2)) ^ 2, 2)

    o = TextBox70.Value * (Pi / 180)
    TextBox18.Value = Application.Round(Tan(Pi / 4 + (TextBox1.Value * (Pi / 180) / 2)) ^ 2, 2)
    TextBox19.Value = Application.Round(TextBox71.Value * (ba + bw) / 2, 2)
    TextBox20.Value = Application.Round(TextBox17.Value * bp, 2)

    TextBox25.Value = Application.Round(TextBox17.Value * TextBox71.Value * (hw + tw), 2)
    TextBox21.Value = TextBox2.Value * TextBox34.Value
    TextBox80.Value = TextBox19.Value
    TextBox81.Value = TextBox20.Value
    TextBox22.Value = TextBox69.Value * TextBox42.Value
    TextBox26.Value = ((bw + tw) ^ 2 * TextBox17.Value * TextBox2.Value) / 2
    TextBox27.Value = TextBox18.Value * TextBox69.Value * h2
    TextBox28.Value = h2 ^ 2 + (TextBox69.Value * TextBox18.Value)

    TextBox58.Value = (h2 - tw) / 2 + tw
    TextBox72.Value = TextBox27.Value
    TextBox59.Value = TextBox58.Value * TextBox72.Value

    TextBox60.Value = h2 / 3
    TextBox73.Value = TextBox28.Value
    TextBox61.Value = TextBox60.Value * TextBox73.Value

    TextBox54.Value = ba - (ba + bw) / 2
    TextBox80.Value = TextBox19.Value
    TextBox55.Value = TextBox54.Value * TextBox80.Value

    TextBox56.Value = bp / 2
    TextBox81.Value = TextBox20.Value
    TextBox57.Value = TextBox56.Value * TextBox81.Value

    TextBox74.Value = TextBox25.Value

    TextBox77.Value = TextBox26.Value

    TextBox75.Value = (bp + ba + bw) / 2
    TextBox78.Value = (h1 + h2) / 3
    TextBox76.Value = TextBox74.Value * TextBox75.Value

    TextBox79.Value = TextBox77.Value * TextBox78.Value

    TextBox24.Value = TextBox31.Value + TextBox39.Value + TextBox35.Value + TextBox43.Value + TextBox80.Value + TextBox81.Value
    TextBox29.Value = Tan(2 * TextBox70.Value * (Pi / 180) / 3) + TextBox24.Value

    TextBox23.Value = TextBox30.Value + TextBox38.Value * TextBox15.Value

    TextBox62.Value = TextBox33.Value + TextBox37.Value + TextBox41.Value + TextBox45.Value + TextBox55.Value + TextBox57.Value + TextBox61.Value + TextBox59.Value
    TextBox63.Value = TextBox76.Value + TextBox79.Value
    TextBox64.Value = (TextBox31.Value + TextBox39.Value + TextBox35.Value + TextBox43.Value + TextBox72.Value + TextBox73.Value + TextBox80.Value + TextBox81.Value) * Tan(2 * (i / 3)) + (bp + ba + bw)

    TextBox65.Value = TextBox62.Value / TextBox63.Value

    If TextBox65 >= 1.5 And TextBox65 < 2 Then
        TextBox66 = "wall stable"
    ElseIf TextBox65 < 1.5 Then
        TextBox66 = "wall unstable"
    Else
        TextBox66 = "wall overdesigned"
    End If

    TextBox67.Value = TextBox64.Value / TextBox29.Value

    If TextBox67 >= 1.5 And TextBox67 < 2 Then
        TextBox68 = "wall stable"
    ElseIf TextBox67 < 1.5 Then
        TextBox68 = "wall unstable"
    Else
        TextBox68 = "wall overdesigned"
    End If
End Sub

Private Sub CommandButton4_Click()
    UserForm1.PrintForm
End Sub

这是我目前为uni分配的代码。我遇到麻烦的行textbox24,textbox62,textbox63。在userform中,它将列出所有十进制输出,例如26.755.742.6,依此类推,它不会添加这些变量,任何帮助都会非常感激,并对文本墙感到抱歉,首先使用此论坛。

0 个答案:

没有答案