vb过程太大,一下代码能否得到简化,谢谢
过程太大,能否简化此代码,谢谢Private Sub Command2_Click()
Pic1.Cls
Dim y() As single
l = Val(Text3.Text)
ReDim y(l * 1000)
Max = 0
Maxx = 0
Min = 0
Minx1 = 0
If Combo1.Text = "简支梁" Then
p1 = Arr(1) '这个要用到调用不同窗体的数组,不知这个能否用for循环简化??
xp1 = Brr(1)
For i = 0 To l * 1000
x = i / 1000
If x < xp1 Then
y(i) = Mp11(l, xp1, p1, x)
Else
y(i) = Mp12(l, xp1, p1, x)
End If
If y(i) > Max Then
Max = y(i)
Maxx = x
End If
Next i
坐标系1 l, Max, Maxx '调用的上面的建坐标系的函数,很好
For i = 0 To l * 1000
x = i / 1000
Pic1.PSet (x, y(i))
If i Mod (50 * l) = 0 Then Pic1.Line (x, y(i))-(x, 0), vbBlack
Next i
Max = 0
Maxx = 0
Min = 0
Minx1 = 0
For i = 0 To l * 1000
x = i / 1000
Select Case x
Case Is <= xp1
y(i) = Fp11(l, xp1, p1, x)
Case Else
y(i) = Fp12(l, xp1, p1, x)
End Select
If y(i) > Max Then
Max = y(i)
Maxx = x
ElseIf y(i) < Min Then
Min = y(i)
Minx1 = x
End If
Next i
If Abs(Max) > Abs(Min) Then
坐标系3 l, Max, Maxx
Else
坐标系4 l, Min, Minx1
End If
For i = 0 To l * 1000
x = i / 1000
If i = 0 Then
Pic2.PSet (x, y(i))
Else
Pic2.Line (x, y(i))-(x - 1 / 1000, y(i - 1)), vbBlack
If i = l * 1000 Then Pic2.Line (x, y(i))-(x, 0), vbBlack
End If
If i Mod (50 * l) = 0 Then Pic2.Line (x, y(i))-(x, 0), vbBlue
Next i
高手们这段代码能否简化为一个函数过程呢?
If y(i) > Max Then
Max = y(i)
Maxx = x
ElseIf y(i) < Min Then
Min = y(i)
Minx1 = x
End If
for循环能否简化为一个过程呢?请高手们指点我这个菜鸟新手,谢谢您们