过程太大,能否简化此代码,谢谢
Private Sub Command2_Click()Pic1.Cls
Dim y()
l = Val(Text3.Text)
ReDim y(l * 1000)
Max = 0
Maxx = 0
Min = 0
Minx1 = 0
If Combo1.Text = "简支梁" Then
If Val(Text1.Text) = 1 Then
If Val(Text2.Text) = 0 And Val(Text11.Text) = 0 Then
p1 = Arr(1)
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
'frm扭转计算.Print Max
坐标系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
End If
Next i
' Unload frm集中力偶
ElseIf Val(Text2.Text) = 1 Then '有一个集中力和一个均布力的时候
p1 = Arr(1)
xp1 = Brr(1)
q1 = Crr(1)
xq1 = Drr(1)
lq1 = Err(1) 'err似乎是错误专用?
If xp1 <= xq1 Then '此处要有三种情况
For i = 0 To l * 1000
x = i / 1000
Select Case x
Case Is < xp1
y(i) = Mp11(l, xp1, p1, x) + Mq11(l, xq1, lq1, q1, x)
Case Is < xq1
y(i) = Mp12(l, xp1, p1, x) + Mq11(l, xq1, lq1, q1, x)
Case Is < (xq1 + lq1)
y(i) = Mp12(l, xp1, p1, x) + Mq12(l, xq1, lq1, q1, x)
Case Else
y(i) = Mp12(l, xp1, p1, x) + Mq13(l, xq1, lq1, q1, x)
End Select
If y(i) > Max Then
Max = y(i)
Maxx = x
End If
Next i 'for...next i 不能与if语句交叉,否则会出错的
坐标系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) + Fq11(l, xq1, lq1, q1, x)
Case Is <= xq1
y(i) = Fp12(l, xp1, p1, x) + Fq11(l, xq1, lq1, q1, x)
Case Is <= xq1 + lq1
y(i) = Fp12(l, xp1, p1, x) + Fq12(l, xq1, lq1, q1, x)
Case Else
y(i) = Fp12(l, xp1, p1, x) + Fq13(l, xq1, lq1, q1, 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
End If
Next i
ElseIf xp1 >= xq1 And xp1 <= (xq1 + lq1) Then
For i = 0 To l * 1000
x = i / 1000
Select Case x
Case Is < xq1
y(i) = Mp11(l, xp1, p1, x) + Mq11(l, xq1, lq1, q1, x)
Case Is < xp1
y(i) = Mp11(l, xp1, p1, x) + Mq12(l, xq1, lq1, q1, x)
Case Is < xq1 + lq1
y(i) = Mp12(l, xp1, p1, x) + Mq12(l, xq1, lq1, q1, x)
Case Else
y(i) = Mp12(l, xp1, p1, x) + Mq13(l, xq1, lq1, q1, x)
End Select
If y(i) > Max Then
Max = y(i)
Maxx = x
End If
Next i 'for...next i 不能与if语句交叉,否则会出错的
坐标系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 <= xq1
y(i) = Fp11(l, xp1, p1, x) + Fq11(l, xq1, lq1, q1, x)
Case Is <= xp1
y(i) = Fp11(l, xp1, p1, x) + Fq12(l, xq1, lq1, q1, x)
Case Is <= xq1 + lq1
y(i) = Fp12(l, xp1, p1, x) + Fq12(l, xq1, lq1, q1, x)
Case Else
y(i) = Fp12(l, xp1, p1, x) + Fq13(l, xq1, lq1, q1, 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
End If
Next i
Else
For i = 0 To l * 1000
x = i / 1000
Select Case x
Case Is < xq1
y(i) = Mp11(l, xp1, p1, x) + Mq11(l, xq1, lq1, q1, x)
Case Is < xq1 + lq1
y(i) = Mp11(l, xp1, p1, x) + Mq12(l, xq1, lq1, q1, x)
Case Is < xp1
y(i) = Mp11(l, xp1, p1, x) + Mq13(l, xq1, lq1, q1, x)
Case Else
y(i) = Mp12(l, xp1, p1, x) + Mq13(l, xq1, lq1, q1, x)
End Select
If y(i) > Max Then
Max = y(i)
Maxx = x
End If
Next i 'for...next i 不能与if语句交叉,否则会出错的
坐标系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 <= xq1
y(i) = Fp11(l, xp1, p1, x) + Fq11(l, xq1, lq1, q1, x)
Case Is <= xq1 + lq1
y(i) = Fp11(l, xp1, p1, x) + Fq12(l, xq1, lq1, q1, x)
Case Is <= xp1
y(i) = Fp11(l, xp1, p1, x) + Fq13(l, xq1, lq1, q1, x)
Case Else
y(i) = (-xp1 * p1) / l - (q1 * lq1 * (xq1 + (lq1 / 2))) / l
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
End If
Next i
End If
End If
End If