Private Sub CommandButton1_Click()
If TextBox1.Text = "" Or TextBox2.Text = "" Then '登陆按钮
MsgBox "请输入帐号(或密码)"
ElseIf TextBox1.Text = "admin" And TextBox2.Text = "888" Then Sheets("首页").Select
ElseIf TextBox1.Text = "abc" And TextBox2.Text = "123" Then Sheets("成员首页").Select
Else
MsgBox "输入错误"
End If
End Sub
为什么我点击后没反映呢?
If TextBox1.Text = "" Or TextBox2.Text = "" Then '登陆按钮
MsgBox "请输入帐号(或密码)"
ElseIf TextBox1.Text = "admin" And TextBox2.Text = "888" Then Sheets("首页").Select
ElseIf TextBox1.Text = "abc" And TextBox2.Text = "123" Then Sheets("成员首页").Select
Else
MsgBox "输入错误"
End If
End Sub
为什么我点击后没反映呢?
If TextBox1.Text = "" Or TextBox2.Text = "" Then '登陆按钮
MsgBox "请输入帐号(或密码)"
ElseIf TextBox1.Text = "admin" And TextBox2.Text = "888" Then Sheets("首页").Activate
ElseIf TextBox1.Text = "abc" And TextBox2.Text = "123" Then Sheets("成员首页").Activate
Else
MsgBox "输入错误"
End If
End Sub
直接用多个IF语句反而更清楚
sheet是引用excel里的表单