如果输入角度为90,我试图使用此代码退出循环。代码不会这样做,但令人沮丧的是,虽然我在其余部分中没有任何完全相同的内容代码我已成功使用相同格式的If
语句。我也成功使用了Exit For
。
以下是我所指的代码。
If Not (Angle = 90) Then
Exit For
End If
***我发现了我的错误,但这里是代码以防任何人遇到类似的错误。我忘了我已经将角度从度数改为弧度了。
*编辑以显示角度的来源:
oriInput = Split(Me.oriInputList.Value, ",")
ReDim toworis(NofLayers - 1)
For p = 0 To NofLayers - 1
toworis(p) = oriInput(p)
Next
这是我出错的地方。我将角度从弧度更改为度数,因此在到达If
语句时角度不是90
For k = 0 To NofLayers - 1 Step 1
toworis(k) = toworis(k) * pi / 180
Next
For j = 0 To NofLayers - 1 Step 1
Angle = toworis(j)
For i = -cntr * 2 + cntrshift To cntr * 2 + cntrshift Step 1
If Not (Angle = 90) Then
Exit For
End If
'1
x11 = 0
x21 = pL
y11 = i * yshift
y21 = i * yshift + Tan(Angle) * pL
'2
x12 = 0
x22 = 0
y12 = i * yshift
y22 = i * yshift - tW / Cos(Angle)
'3
x13 = 0
x23 = pL
y13 = i * yshift - tW / Cos(Angle)
y23 = i * yshift - tW / Cos(Angle) + Tan(Angle) * pL
'4
x14 = pL
x24 = pL
y14 = i * yshift + Tan(Angle) * pL
y24 = i * yshift - tW / Cos(Angle) + Tan(Angle) * pL
Set line2D3 = factory2D1.CreateLine(x11, y11, x21, y21)
Set line2D4 = factory2D1.CreateLine(x12, y12, x22, y22)
Set line2D5 = factory2D1.CreateLine(x13, y13, x23, y23)
Set line2D6 = factory2D1.CreateLine(x14, y14, x24, y24)
Next
如果角度为90,则应创建图层
For l = cntrshift To cntr3 Step 1
If (Angle <> 90) Then
Exit For
End If
'1
x11 = l * tW * (sT + 1) + shift * tW
x21 = x11
y11 = pW
y21 = 0
'2
x12 = x11
x22 = x11 + tW
y12 = 0
y22 = 0
'3
x13 = x11 + tW
x23 = x13
y13 = 0
y23 = pW
'4
x14 = x11 + tW
x24 = x11
y14 = pW
y24 = pW
Set line2D3 = factory2D1.CreateLine(x11, y11, x21, y21)
Set line2D4 = factory2D1.CreateLine(x12, y12, x22, y22)
Set line2D5 = factory2D1.CreateLine(x13, y13, x23, y23)
Set line2D6 = factory2D1.CreateLine(x14, y14, x24, y24)
Next