| 网站首页 | 业界新闻 | 群组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
 跟大牛学C++学算法数据结构

已结贴   问题点数：20  回复次数：2

Dim i As Integer
Private Sub UserForm_Initialize()
Dim Arr
Arr = Sheet1.Range("a1:a10")
Me.ComboBox1.List = Application.Transpose(Arr)
End Sub

Private Sub CommandButton1_Click()
Dim username As String
Dim password As String
Dim r_rowcount As Integer

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 "登录成功"

Else

i = i + 1
If i <= 3 Then
MsgBox "您输入的用户名或密码不正确，请重新输入"

TextBox1.SetFocus
Else
MsgBox "您输入错误超过三次，请按确定退出"
End If
End If
Next i
End Sub

Private Sub CommandButton2_Click()
End

End Sub

Private Sub Label2_Click()

End Sub

Private Sub UserForm_Click()

End Sub

得分:10

得分:10

public j

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
end if
next i
if i>r_rowcount then'如果没有匹配到
j=j+1'计数的，在打开表和匹配前定义
If j <= 3 Then
MsgBox "您输入的用户名或密码不正确，请重新输入"
TextBox1.SetFocus
Else
MsgBox "您输入错误超过三次，请按确定退出"
End If
End If

[此贴子已经被作者于2018-4-9 18:34编辑过]

• 3
• 1/1页
• 1

Powered by Discuz, Processed in 0.056332 second(s), 8 queries.