请大神看看,有没有需要简化的
![](zzz/editor/img/code.gif)
Public DS As Double Public DC As Double Public Y As Double Public S As Double Public h As Double Private Sub Command1_Click() pi = 4 * Atn(1) DS = Val(Text1(0).Text) DC = Val(Text1(1).Text) h = Val(Text1(2).Text) Dim i As Integer Dim F As Double Dim n As Integer '项目个数 Dim sum As Double n = 0 sum = 0 For i = 0 To Text7.UBound F = DS + DC * Sin(Val(Text2(i).Text) * pi / 180) ^ 2 'F值 If Val(Text3(i)) > 0 Then Text5(i) = Round(Abs(F) * (Val(Text4(i))) ^ 2 / 2000 / (Val(Text3(i)) - h) _ + (Val(Text3(i)) - h) / 2000 + 1, 5) sum = sum + Text5(i) n = n + 1 End If Next If n > 0 Then Text6.Text = Round(sum / n, 4) Else MsgBox "容我卜一卦,嘿!你今天要中500万!" End If End Sub Private Sub Command2_Click() End End Sub Private Sub Command3_Click() pi = 4 * Atn(1) DS = Val(Text1(0).Text) DC = Val(Text1(1).Text) h = Val(Text1(2).Text) Dim i As Integer For i = 0 To Text7.UBound Text7(i).Text = Round(DS + DC * Sin(Val(Text2(i).Text) * pi / 180) ^ 2, 3) Next End Sub Private Sub Command4_Click() Dim t As Control For Each t In Me.Controls If TypeOf t Is TextBox Then t.Text = "" Next End Sub Private Sub form_load() Dim i As Long For i = 0 To Text1.UBound Text1(i).Text = "" Next Dim t As Object For Each t In Text2 t.Text = "" Next Dim t1 As Object For Each t1 In Text3 t1.Text = "" Next Dim t2 As Object For Each t2 In Text4 t2.Text = "" Next Dim t3 As Object For Each t3 In Text5 t3.Text = "" Next Dim t4 As Object For Each t4 In Text7 t4.Text = "" Next Text6.Text = "" End Sub
小白到处求大神终于写完一个简单的程序了,请大家看看有没有需要简化,需要改进的地方。谢谢