一道编程问题

来源:百度知道 编辑:UC知道 时间:2024/09/23 04:36:36
用VB条件语句来编一个写密码,且输入的次数为3的程序,我是初二的,不要哪么难

Dim TruePassword As String
Dim InputPassword As String
Dim Flag As Boolean

TruePassword = "123456"
Flag = False

For I = 1 To 3
InputPassword = InputBox("请输入密码")
If InputPassword = TruePassword Then
Flag = True
Exit For
End If
Next

If Not Flag Then
MsgBox "你已连续三次输入错误密码"
Else
MsgBox "密码正确"
End If