VB用户和密码框
我想要个多用户登陆框,用户登陆成功后出现第二个窗体。比如用户一"123"密码"456"用户二"abc"密码"cmd"密码错误有提示,密码或帐号无输入也有提示。代码怎么写啊...
我想要个多用户登陆框,用户登陆成功后出现第二个窗体。
比如用户一"123"密码"456"用户二"abc"密码"cmd"
密码错误有提示,密码或帐号无输入也有提示。代码怎么写啊。
单单是用户登录 展开
比如用户一"123"密码"456"用户二"abc"密码"cmd"
密码错误有提示,密码或帐号无输入也有提示。代码怎么写啊。
单单是用户登录 展开
3个回答
展开全部
'比如用户一"123"密码"456"用户二"abc"密码"cmd"
'密码错误有提示,密码或帐号无输入也有提示。代码怎么写啊。
Private Sub Command1_Click()
If Text1 = "" Or Text2 = "" Then
MsgBox "没输入完整登录信息呀!"
Exit Sub
End If
If Text1 = "123" Or Text1 = "abc" Then '判断用户名正确否
'下面是判断密码
If (Text1 = "123" And Text2 = "456") Or (Text1 = "abc" And Text2 = "cmd") Then
form2.Show
Unload Me
Else
Text2 = ""
MsgBox "密码错误!!“"
Text2.SetFocus
End If
Else
Text1 = ""
MsgBox "用户名错误!!“"
Text1.SetFocus
End If
End Sub
Private Sub Form_Load()
Text1 = ""
Text2 = ""
Command1.Caption = "登录"
Command1.Default = True
Me.Show
Text1.SetFocus
End Sub
'密码错误有提示,密码或帐号无输入也有提示。代码怎么写啊。
Private Sub Command1_Click()
If Text1 = "" Or Text2 = "" Then
MsgBox "没输入完整登录信息呀!"
Exit Sub
End If
If Text1 = "123" Or Text1 = "abc" Then '判断用户名正确否
'下面是判断密码
If (Text1 = "123" And Text2 = "456") Or (Text1 = "abc" And Text2 = "cmd") Then
form2.Show
Unload Me
Else
Text2 = ""
MsgBox "密码错误!!“"
Text2.SetFocus
End If
Else
Text1 = ""
MsgBox "用户名错误!!“"
Text1.SetFocus
End If
End Sub
Private Sub Form_Load()
Text1 = ""
Text2 = ""
Command1.Caption = "登录"
Command1.Default = True
Me.Show
Text1.SetFocus
End Sub
展开全部
Option Explicit
Public appdisk As String
Public conn As New ADODB.Connection
Public Rs As New ADODB.Recordset
Public db As String
Private sSQL As String
Private Sub Command1_Click()
If Trim(Text1.Text) = "" Then
MsgBox "must input", vbCritical, "error"
Text1.SetFocus
Exit Sub
End If
If Trim(Text2.Text) = "" Then
MsgBox "must input", vbCritical, "error"
Text2.SetFocus
Exit Sub
End If
sSQL = "select * from USERID where id='" & Trim(Text1.Text) & "'"
Rs.Open sSQL, conn, adOpenKeyset, adLockPessimistic
If Rs.EOF = True Then
MsgBox "no this user", vbCritical, "error"
Text1.SetFocus
Rs.Close: Set Rs = Nothing
Exit Sub
End If
Rs.Close: Set Rs = Nothing
sSQL = "select * from USERID where id='" & Trim(Text1.Text) & "' and password='" & Trim(Text2.Text) & "'"
Rs.Open sSQL, conn, adOpenKeyset, adLockPessimistic
If Rs.EOF = True Then
MsgBox "password is wrong", vbCritical, "error"
Text2.SetFocus
Rs.Close: Set Rs = Nothing
Exit Sub
Else
If Val(Rs!Levels) = 0 Then
Form2.Show 1
Else
Form3.Show 1
End If
End If
Rs.Close: Set Rs = Nothing
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
Dim i As Integer
On Error GoTo Err
appdisk = Trim(App.Path)
If Right(appdisk, 1) <> "\" Then appdisk = appdisk & "\"
db = appdisk
db = "Provider=MSDAORA.1;Password=chun;User ID=chun;Data Source=chun;Persist Security Info=True"
conn.CursorLocation = adUseClient
conn.Open db
Exit Sub
Err:
MsgBox Err.Number
Unload Me
End Sub
Public appdisk As String
Public conn As New ADODB.Connection
Public Rs As New ADODB.Recordset
Public db As String
Private sSQL As String
Private Sub Command1_Click()
If Trim(Text1.Text) = "" Then
MsgBox "must input", vbCritical, "error"
Text1.SetFocus
Exit Sub
End If
If Trim(Text2.Text) = "" Then
MsgBox "must input", vbCritical, "error"
Text2.SetFocus
Exit Sub
End If
sSQL = "select * from USERID where id='" & Trim(Text1.Text) & "'"
Rs.Open sSQL, conn, adOpenKeyset, adLockPessimistic
If Rs.EOF = True Then
MsgBox "no this user", vbCritical, "error"
Text1.SetFocus
Rs.Close: Set Rs = Nothing
Exit Sub
End If
Rs.Close: Set Rs = Nothing
sSQL = "select * from USERID where id='" & Trim(Text1.Text) & "' and password='" & Trim(Text2.Text) & "'"
Rs.Open sSQL, conn, adOpenKeyset, adLockPessimistic
If Rs.EOF = True Then
MsgBox "password is wrong", vbCritical, "error"
Text2.SetFocus
Rs.Close: Set Rs = Nothing
Exit Sub
Else
If Val(Rs!Levels) = 0 Then
Form2.Show 1
Else
Form3.Show 1
End If
End If
Rs.Close: Set Rs = Nothing
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
Dim i As Integer
On Error GoTo Err
appdisk = Trim(App.Path)
If Right(appdisk, 1) <> "\" Then appdisk = appdisk & "\"
db = appdisk
db = "Provider=MSDAORA.1;Password=chun;User ID=chun;Data Source=chun;Persist Security Info=True"
conn.CursorLocation = adUseClient
conn.Open db
Exit Sub
Err:
MsgBox Err.Number
Unload Me
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
说的还不够详细,如果单单是用户登录(自然都是多用户,因为用户名可以随便选择 这样的话 代码很简单 网上一大堆) ,还是 :不同的用户 从不同的(窗口)地方同时或不同时登录呢?
如果是前者:仅一个用户登录,又何必去显示 其它用户的资料呢?那么如果是一个窗口登录,是不能同时登录2个用户的.没有这样的事情
等待你赶紧补充...
如果是前者:仅一个用户登录,又何必去显示 其它用户的资料呢?那么如果是一个窗口登录,是不能同时登录2个用户的.没有这样的事情
等待你赶紧补充...
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询