private Sub cmdok_Click() '根据用户名查找用户记录 logindata.Recordset.FindFirst("tuserid='"=txtusername.Text+"'") If Not logindata.Recordset.NoMatch Then '用户输入了正确的密码 If txtPassword.Text=logindata.Recordset.Fields("tpassword") Then '隐藏当前登录窗体 Me.Visible=False '显示程序主窗体 Main.Show '用户输入的密码不正确 Else i=MsgBox("请输入正确的密码!",vbokonly,"密码错误") End If '没有找到该用户记录 Else MsgBox"用户名、密码不正确!" End If End Sub
直接在同一个form上,放上个文本框text1和按妞command1 在command1的click事件里写如下代码: if text1.text="密码" then form1.enable=ture text1.visible=false command1.visible=false else form1.enable=false text1.text="" msgbox "密码错误,请重新输入",1,"提醒" text1.setfouce(?不记得单词) endif 在form的load事件里加: me.enable=false
private sub form_load()
frmpass.show vbmodal
end sub
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 最新版本:20070130http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
让这个窗体首先出来就是了
'根据用户名查找用户记录
logindata.Recordset.FindFirst("tuserid='"=txtusername.Text+"'")
If Not logindata.Recordset.NoMatch Then
'用户输入了正确的密码
If txtPassword.Text=logindata.Recordset.Fields("tpassword") Then
'隐藏当前登录窗体
Me.Visible=False
'显示程序主窗体
Main.Show
'用户输入的密码不正确
Else
i=MsgBox("请输入正确的密码!",vbokonly,"密码错误")
End If
'没有找到该用户记录
Else
MsgBox"用户名、密码不正确!"
End If
End Sub
在command1的click事件里写如下代码:
if text1.text="密码" then
form1.enable=ture
text1.visible=false
command1.visible=false
else
form1.enable=false
text1.text=""
msgbox "密码错误,请重新输入",1,"提醒"
text1.setfouce(?不记得单词)
endif
在form的load事件里加:
me.enable=false
在form的load里面,不能加:me.enable=false,否则不能操作