做的是学生信息管理系统,照着书做但出现下面的问题,书也看不明白。请高手帮忙看一下。
Quote:
运行后提示:“编译错误:未找到方法或数据成员”.是错在下面这个.mnUsertype
With frmMain
.mnUserType = mnUserType
.msUsername = user
Option Explicit
Public LoginSucceeded As Boolean
Dim mnUserType As Integer
Private Sub optUserType_Click(Index As Integer)
mnUserType = Index
End Sub
Private Sub Form_Load()
optUserType(0).Value = True
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
'取得用户输入的用户名和密码
Dim user As String, pwd As String
user = Trim(txtUser)
pwd = Trim(txtPwd)
'根据不同的身份,选择不同的表用以查询
Dim r As New ADODB.Recordset
Set r = DataEnv.rssqlSeek
Dim strSQL As String
Select Case mnUserType
Case 0: '若身份为管理员
strSQL = "select * from 系统人员表 where name=" & user & "and pwd=" & pwd & ""
Case 1: '若身份为学生
strSQL = "select * from 学生信息表 where name=" & user & " and serial=" & pwd & ""
End Select
On Error Resume Next
'查询DataEnv.rssqlSeek的状态,如果已经打开,则先关闭
If r.State = adStateOpen Then r.Close
r.Open strSQL '根据strSQL的内容刷新DataEnv.rssqlSeek
'用户密码错误的次数,如果错误次数超过3次,则退出系统
Static nTryCount As Integer
If r.EOF Then '登录失败
MsgBox "对不起,无此用户或者密码不正确!请重新输入!!", vbCritical, "错误"
txtUser.SetFocus
txtUser.SelStart = 0
txtUser.SelLength = Len(txtUser)
nTryCount = nTryCount + 1
If nTryCount >= 3 Then
MsgBox "您无权操作本系统!", vbCritical, "错误"
Unload Me
End If
Else '登录成功
'显示MDI窗体,并将用户类型和用户名传到MDI窗体中的mnUserType, msUserName中
With frmMain
.mnUserType = mnUserType
.msUsername = user
End With
Load frmMain
frmMain.Show
Unload Me
End If
End Sub