请问用VB6。0如何写1个程序的登陆窗口要专业点的?

1个form12个text的控件text1.text(用户名)和text2.text(密码)2个Command1控件Command1(确定)和Command1(取消)当C... 1个form1
2个text的控件 text1.text(用户名) 和text2.text(密码)
2个Command1控件Command1(确定) 和Command1(取消)
当Command1确定按扭 按下后密码帐号都是对的 就进入 form2
怎么写的?
展开
 我来答
dotma
2008-04-18 · 超过20用户采纳过TA的回答
知道答主
回答量:95
采纳率:100%
帮助的人:32.6万
展开全部
Two buttons ,two textbox ,one frame

Option Explicit

Dim pname As String
Dim pkey As String
Dim DB As Database
Dim rd1 As Recordset
Public ok As Boolean

'Private Const MAX_FILENAME_LEN = 256
Private Sub cmdCancel_Click()
ok = False
rd1.Close
DB.Close
Unload Me
End
End Sub

Private Sub cmdOK_Click()
Dim DogAddr As Long ' The address read
Dim DogBytes As Long ' The number of bytes read
Dim DogDataStr As String ' The data read
Dim DogDataInt As Long
Dim DogDataDouble As Double
Dim Ret As Long ' The return value
Dim DogUser As String
Dim DogKeys As String
'ToDo: 创建测试密码是否正确
'检查正确密码
If Trim(txtUserName.Text) <> "" Then
If Trim(txtPassword.Text) <> "" Then

rd1.FindFirst " username='" + Trim(txtUserName.Text) + "'"
If rd1.NoMatch Then '没有发现库中有用户,在dogkey中找
MsgBox "用户不存在(注意输入大小写) ,请再试一次!", vbCritical, "登录"
Call txtUserNameGetFocus
Else

If Trim(txtPassword.Text) = Trim(rd1("userKey").Value) Then
'做出相应的标志,处理动作
MsgBox "祝贺你成功登录系统.", vbInformation, "登录"
ok = True '登陆标志
UsName = txtUserName.Text
rd1.Close
DB.Close
Unload Me
Else
MsgBox "密码错误 (注意输入大小写) ,请再试一次!", vbCritical, "登录"
Call txtPasswordGetFocus
End If

End If

Else: MsgBox "请输入你的密码!", vbInformation, "登录"
Call txtPasswordGetFocus
End If
Else
MsgBox "请输入你的姓名!", vbInformation, "登录"
End If
End Sub
Private Sub ChkDog()
Private Sub txtPasswordGetFocus()
txtPassword.SetFocus
txtPassword.SelStart = 0
txtPassword.SelLength = Len(txtPassword.Text)
End Sub

Private Sub txtUserNameGetFocus()
txtUserName.SetFocus
txtUserName.SelStart = 0
txtUserName.SelLength = Len(txtUserName.Text)
End Sub

Private Sub Form_Load()
'App.HelpFile = App.Path + "\WHELP.HLP"
'OpenDatabase(DatabaseName, False,False, ";Pwd=密码")
Set DB = OpenDatabase(App.Path + "\Access.mdb", False, False, ";pwd=ma")
Set rd1 = DB.OpenRecordset("kkey", dbOpenSnapshot)
If rd1.RecordCount = 0 Then Exit Sub
pname = rd1("username")
pkey = rd1("userkey")
End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式