标题: 如何跳出内循环 [打印本页] 作者: shuishixingyu 时间: 2009-3-24 19:06 标题: 如何跳出内循环 Function orgCode(vLength)
Dim MyArray,MyString,vStr,vArr, Msg
MyString = "***********"
MyArray = Split(MyString, ",", -1, 1)
For i = 1 To len(vLength)
vStr = Mid(vLength, i, 1)
For j = 0 To 61
vArr = MyArray(j)
If Trim(vStr) = Trim(vArr) Then
Msg = Msg & MyArray(j)
exit for
End If
Next
Next
If Trim(vLength) = Trim(Msg) Then
Reporter.ReportEvent micPass,"提示","********"
Else
Reporter.ReportEvent micPass,"提示","********"
End If
End Function
调用方法 orgCode(Len1) ,Len1=9,请问如何在Trim(vStr) = Trim(vArr)时跳出内循环,使脚本的效率提高? 作者: blueeagle9999 时间: 2009-3-24 20:31
For j = 0 To 61
vArr = MyArray(j)
If Trim(vStr) = Trim(vArr) Then
Msg = Msg & MyArray(j)
exit for
End If
Next
你这EXIT FOR不是已经跳出内循环了吗??作者: shuishixingyu 时间: 2009-3-24 22:34
哦,那个Exit For 是我试试用的,结果是加了后跳出整个循环了作者: lyscser 时间: 2009-3-24 22:38
换一种循环,一个用while一个用for或者一个用do就好控制了作者: shuishixingyu 时间: 2009-3-24 22:47
请问应该怎么写啊,想不清楚了作者: lyscser 时间: 2009-3-24 22:53
For i = 1 To len(vLength)
vStr = Mid(vLength, i, 1)
j = 0
Do While j < 62
vArr = MyArray(j)
If Trim(vStr) = Trim(vArr) Then
Msg = Msg & MyArray(j)
Exit do
Else
j = j + 1
End If
Loop
Next作者: shuishixingyu 时间: 2009-3-24 23:06
呵呵,谢谢啊,比前面效率要高了