vb提示编译错误 变量未定义

来源:百度知道 编辑:UC知道 时间:2024/06/28 07:23:34
Option Explicit
Public operator As String
Public LoginSucceeded As Boolean
Private Sub cmdCancel_Click()
LoginSucceeded = False
Me.Hide
End Sub
Private Sub cmdOK_Click()
operator = txtUserName
Select Case operator
Case Is = "13300"
If txtPassword = "820801" Then
LoginSucceeded = True
Me.Hide
MsgBox "您好,于经理!欢迎使用酒店管理系统!"
Form2.Show
frmxinxibiao.txtFields(15).Text = 13300
Form4.txtFields(8).Text = 13300
frmyubiao.txtFields(9).Text = 13300
Else
MsgBox "密码无效,请重试!", , "登录"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
End If
Case Is = "12300"
If txtPassword = "820802" Then
LoginSucceeded = True
Me.Hide
MsgBox "您好,董祎!欢迎使用酒店管理系统!"
Form2.Show
frmxinxibiao.txtFields(15).Text = 12300
Form4.txtFi

用数据库吧,你需要建立一个数据库来保存这些用户的登录信息。
数据库的设计包括两个字段,分别保存用户名和密码。数据库名叫“yusion”
表名叫“user”

写代码之前你需要引用ado 控件
具体的办法是添加部件的对话框中选中
Microsoft ActiveX Data ...Object Controls 2.6 这句不是很记得怎么写了。
Private Sub command1_click()
dim conn as new adodb.connection
dim rs as new adodb.recordset
dim str as string
Static logintimes As Integer
dim sql as string
str = App.Path
If Right(str, 1) <> "\" Then
str = str + "\"
End If
str = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & str & "\yusion.mdb"
conn.open str ‘这里是打开数据库
rs.cursorlocation=aduseclient
sql="select * from user where 用户名='" & text1.text & "'"
rs.open sql,conn,adopenkeyset.adlockpessimistic ‘这里打开记录_集
if rs.recordset.eof and rs.recordset.bof then
msgbox "没有此用户"
else
if trim(text2.text