複製程式
dim wrongval as integer '定義wrongval 為integer
Dim username, password As String
Dim LoginSuccess As Boolean = False
wrongval = 0 '將wrongval 預設等於0
Do Until LoginSuccess
username = InputBox("Username Please")
password = InputBox("Password Please")
If username = "Peter" And password = "1234" Then
LoginSuccess = True
else
wrongval +=1 ' 判斷如果不等於的話 則wrongval + 1
End If
if wrongval >3 then ' 判斷如果錯誤次數超過3則秀出彈跳視窗
messagebox.show("已輸入三次錯誤!!")
end if
Loop
MsgBox ("Login success")
不曉得你要的錯誤畫面是什麼 隨便寫了一段 你自己看看吧
有附加說明 有問題的話 可以PM詢問~