作者A1pha ([αλφα])
看板Visual_Basic
标题[VB6 ] 杞人忧天..
时间Wed Jan 10 17:43:06 2007
(程式码在下面)
我写了一个函式来判断是否所有该输入的资料都输入的正确无误,
利用回圈来判断。
原本没有那个 Exit For的,(红色文字)
後来因为发现,假使使用者有错不只一个地方,
那麽错误讯息就会弹出不止一次...
因此我就加了Exit For,在发现一次错误之後,就跳出回圈,
这样就只会跳出一次错误讯息。
但是後来想想,这样跳出来的时候,感觉上 If CheckInput(i) = 1 这边,
没有一个结尾...感觉有点怕怕的@@"
感觉就像是使用未定义过的变数一样==
虽然测试是没有错误...但是不太敢肯定..囧
在想需不需要在Exit For前面加上一个 End If (黄色文字)?
还是说,直接用Exit For就可以帮你结束If?
因为没有基础所以没有自信...囧
因此就杞人忧天了...囧
--
Function AllOK() As Boolean
Dim i, check As Integer
For i = 0 To 14
If CheckInput(i) = 1 Then
check = 1
SendMsg
(End If)
Exit For
End If
Next i
If check = 1 Then AllOK = False Else AllOK = True
End Function
--
"Every kid who has dreamed of being a baseball player has stood in his front
yard with a bat and said to himself, "Bottom of the ninth, Game 7 of the
World Series, the bases are loaded," and then envisioned hitting a home run
to win the game. My job is to shatter that dream."
By Huston Street
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 124.8.68.154
※ 编辑: A1pha 来自: 124.8.68.154 (01/10 17:44)
1F:→ A1pha:突然想到...好像可以用 do Until....loop 囧 01/10 18:28
2F:→ A1pha:这样就不需要用Exit For了 01/10 18:29
3F:推 fumizuki:不需要多打 end if... 01/12 06:33