关于用VB做的登录界面的问题,VB高手请进

王朝知道·作者佚名  2010-08-12
窄屏简体版  字體: |||超大  
 
分類: 教育/科學 >> 學習幫助
 
問題描述:

这是我在做学生管理系统时,代码出现了问题,请高手帮我看看,帮我改改,谢谢

Private Sub cmdOK_Click()

Dim sql As String

sql = "select userpassword from use where username='" & txtUserName & "'"

If txtUserName.Text = "" Then

MsgBox "请填写用户名!", vbOKOnly + vbInformation, "注意"

txtUserName.SetFocus

Exit Sub

ElseIf txtPassword.Text = "" Then

MsgBox "请填写密码!", vbOKOnly + vbInformation, "注意"

txtPassword.SetFocus

Exit Sub

End If

Adodc1.RecordSource = sql

Adodc1.Refresh

If Not Adodc1.Recordset.EOF Then

If Adodc1.Recordset!UserName <> txtUserName Then

MsgBox "用户名错误!"

txtUserName.SetFocus

txtUserName = ""

End If

Else

If Adodc1.Recordset!userpassword <> txtPassword Then

MsgBox "密码错误!"

txtPassword.SetFocus

txtPassword = ""

Else

MDIForm1.Show

Unload Me

End If

End If

End Sub

或者帮我写一个也行,好了的再给你加分,万般感谢!

參考答案:

Private Sub cmdOK_Click()

Dim sql As String

sql = "select userpassword from use where username='" & txtUserName & "'"

If txtUserName.Text = "" Then

MsgBox , vbOKOnly + vbInformation,

txtUserName.SetFocus

Exit Sub

ElseIf txtPassword.Text = "" Then

MsgBox , vbOKOnly + vbInformation,

txtPassword.SetFocus

Exit Sub

End If

Adodc1.RecordSource = sql

Adodc1.Refresh

If Not Adodc1.Recordset.EOF Then

If Adodc1.Recordset!UserName <> txtUserName Then

MsgBox

txtUserName.SetFocus

txtUserName = ""

End If

Else

If Adodc1.Recordset!userpassword <> txtPassword Then

MsgBox

txtPassword.SetFocus

txtPassword = ""

Else

MDIForm1.Show

Unload Me

End If

End If

End Sub

小贴士:① 若网友所发内容与教科书相悖,请以教科书为准;② 若网友所发内容与科学常识、官方权威机构相悖,请以后者为准;③ 若网友所发内容不正确或者违背公序良俗,右下举报/纠错。
 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航