|
请高手帮忙看看,错在那里了?我有一个电子表,用“管理员“名称登录,登录密码是9999.登录后,在“查询表“中点击“查询”按钮“,当用汉字:管理员、王五、刘根林等名称登录时,一切正常,就是不能用数字:107、109等数字格式登录查询,就提示:运行错误‘13’,类型不匹配。VBA代码停止在: If b <> Sheets("名称").Cells(c, 2) Then这一句(下面代码红色部份)Private Sub CommandButton1_Click() a = UserForm11.TextBox1.Value
b = Val(UserForm11.TextBox2.Value)
d = Application.CountIf(Sheets("名称").Range("a2:a1000"), a)
If a = "" Then MsgBox "对不起,您没有输入用户名,不能登录", 16, "敬告": Exit Sub
If b = "" Then MsgBox "对不起,您没有输入密码,不能登录", 16, "敬告": Exit Sub
If d = 0 Then MsgBox "对不起,没有这个用户,不能登录", 16, "敬告": Exit Sub
If d > 0 Then
c = Application.Match(a, Sheets("名称").Range("a1:a1000"), 0)
If b <> Sheets("名称").Cells(c, 2) Then
MsgBox "对不起,密码错误,不能登录", 16, "敬告": Exit Sub
ElseIf a = "管理员" And b = 9999 Then
Unload Me
Application.Visible = True '显示工作簿
ThisWorkbook.Worksheets("名称").Visible = xlSheetVisible '显示被隐藏的工作表
ThisWorkbook.Worksheets("数据").Visible = xlSheetVisible '显示被隐藏的工作表
Else
[Z1] = "房间号"
[Z2] = a
Sheets("数据").[A3:R196].AdvancedFilter 2, [Z1:Z2], [A3:R3]
[Z1:Z2] = ""
Unload Me
Application.Visible = True '显示工作簿
End If
End If
End Sub
请高手们帮我看看,错在哪里了,如何修改后?才能用数字形式的用户名登录查询。谢谢了!file:///D:/%E7%94%A8%E6%88%B7%E7%9B%AE%E5%BD%95/Documents/Tencent%20Files/1789627716/Image/C2C/]V_Y625@I23USX%60WMJ_]LQX.png
名称 | 密码 | 管理员 | 9999 | 107 | 107 | 王五 | 110 | 109 | 201 | 刘根林 | 202 |
第三行加一句
Private Sub CommandButton1_Click()
a = UserForm11.TextBox1.Value
If IsNumeric(a) Then a = a * 1
|
|