vb用户怎么登录界面?用户登陆的代码是多少?

vb用户怎么登录界面?用户登陆的代码是多少?,第1张

vb登陆程序源代码\x0d\x0a\x0d\x0a你可以这样做建一个模块在里面输入下列\x0d\x0aPublic conn As ADODB.Connection\x0d\x0aSub main()\x0d\x0aSet conn = New ADODB.Connection\x0d\x0a conn.ConnectionString = "Provider=SQLOLEDB.1Persist Security Info=False" _\x0d\x0a + "User ID=sapassword=saInitial Catalog=您的数据库名Data Source=127.0.0.1"\x0d\x0aconn.Open\x0d\x0afrom1.Show ’登录界穗慧面\x0d\x0aEnd Sub\x0d\x0a\x0d\x0a再在登录界面“确定”下写入如下代码:\x0d\x0aPrivate Sub Command1_Click()\x0d\x0a If id.Text = "" Then\x0d\x0aMsgBox "用户名不能为空!", vbOKOnly + vbInformation, "友情提示"\x0d\x0aid.SetFocus\x0d\x0aExit Sub\x0d\x0aEnd If\x0d\x0aIf password.Text = "" Then\x0d\x0aMsgBox "密码不能为空!", vbOKOnly + vbInformation, "友情提示"\x0d\x0apassword.SetFocus\x0d\x0aExit Sub\x0d\x0aEnd If\x0d\x0a\x0d\x0aDim strSQl As String\x0d\x0astrSQl = "select * from Users where users_name='" &Trim$(id.Text) &"' and password='" &Trim$(password.Text) &"' "\x0d\x0a\x0d\x0aDim str As New ADODB.Recordset\x0d\x0aSet str = New ADODB.Recordset\x0d\x0astr.CursorLocation = adUseClient\x0d\x0astr.Open strSQl, conn, adOpenStatic, adLockReadOnly\x0d\x0a\x0d\x0aWith str\x0d\x0aIf .State = adStateOpen Then .Close\x0d\x0a.Open strSQl\x0d\x0aIf .EOF Then\x0d\x0aTry_times = Try_times + 1\x0d\x0aIf Try_times >= 3 Then\x0d\x0aMsgBox "您已经三次虚漏尝试进入本系统,均不成功,系统将自动关闭", vbOKOnly + vbCritical, "警告"\x0d\x0aUnload Me\x0d\x0aElse\x0d\x0aMsgBox "对不起,用户名差族烂不存在或密码错误 !", vbOKOnly + vbQuestion, "警告"\x0d\x0aid.SetFocus\x0d\x0aid.Text = ""\x0d\x0apassword.Text = ""\x0d\x0aEnd If\x0d\x0aElse\x0d\x0a\x0d\x0aUnload Me\x0d\x0a\x0d\x0a Form2.Show’登录进入的另一个界面\x0d\x0a\x0d\x0aEnd If\x0d\x0aEnd With\x0d\x0a\x0d\x0aEnd Sub

'添加好控件,把代码复制到窗体模块可以了吧。

'label1,Label2,Text1

'Command1:确定,command2:重输

PrivateSubForm_Load()

Text1.PasswordChar=\"*\"

Text1.MaxLength=6

Command1.Enabled=False

Command2.Visible=False

Label2.Visible=False

EndSub

PrivateSubCommand1_Click()

IfText1.Text=\"123456\"Then

Label2.ForeColor=vbBlue

Label2.Caption=\"欢迎进入应用程序!\"世扰改

Else

Label2.ForeColor=vbRed

Label2.Caption=\"密码错李凳误!\"

EndIf

Label2.Visible=True

EndSub

PrivateSubCommand2_Click()

Text1.Text=\"\"

Command1.Enabled=False

Command2.Visible=False

EndSub

PrivateSubText1_Change()

IfText1.Text<>\"\"搜判Then

Command1.Enabled=True

Command2.Visible=True

Else

Label2.Visible=False

Command1.Enabled=False

Command2.Visible=False

EndIf

EndSub


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/12312576.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存