求助贴,制作一个提取Excel表内用户名密码的登录程序
前面的部分都差不多了,但是就是需要设置登录三次错误自动退出,我这也写有什么错误吗 ?除了用户1对应密码1正确,其他两个就算输入正确的密码也会接连跳出提示错误,然后关闭程序。求助三次登录错误部分怎么写。Dim i As Integer
Private Sub UserForm_Initialize()
Dim Arr
Arr = Sheet1.Range("a1:a10")
= Application.Transpose(Arr)
End Sub
Private Sub CommandButton1_Click()
Dim username As String
Dim password As String
Dim r_rowcount As Integer
username = ComboBox1.Value
password = TextBox1.Value
r_rowcount = Sheets("sheet1").UsedRange.Rows.Count
For i = 1 To r_rowcount
If username = Worksheets(1).Cells(i, 1).Value And password = Worksheets(1).Cells(i, 2).Value Then
MsgBox "登录成功"
图片运动.Show
Else
i = i + 1
If i <= 3 Then
MsgBox "您输入的用户名或密码不正确,请重新输入"
TextBox1.SetFocus
Else
MsgBox "您输入错误超过三次,请按确定退出"
Unload Me
End If
End If
Next i
End Sub
Private Sub CommandButton2_Click()
Unload Me
End
End Sub
Private Sub Label2_Click()
End Sub
Private Sub UserForm_Click()
End Sub