[求助]
大家好啊,我是VB的初学者!最近没事照着教材做了几个小小的系统!但运行时总出错!而且错误多数是-"变量没定义"代码我基本是是安书上写的.不知怎么硬是出错!我反凝是没连接到数据库......
真是急死我了,那位知道的大哥帮个忙啊,帮我解决一下这个问题.
登录窗体代码如下:
Option Explicit
Dim loginsucceeded As Boolean
Private Sub cmdcance1_click()
Unload Frmlogin
Introfrm.Show
End Sub
Private Sub cmdOK_Click()
If txtusername.Text = "administrator" Then
loginsuccessded = verify(txtusername, txtpassword)
If (loginsuccessded = ture) Then
id = textusenrname
admin = True
Unload Frmlogin0
MDIMainfrm.Show
End If
Else
loginsuccessded = verify(txtusername, txtpassword)
If (loginsuccessded = True) Then
id = textusername
admin = False
Unload Frmlogin
MDIMainfrm.Show
End If
End If
End Sub
Function verify(userid As String, txtpwd As String) As Boolean
Dim idinfo As Recordset
Dim sqlstr As String
sqlstr = "select 学号,密码 from 密码 where 学号= '" & userid & "'"
Set idinfo = coursedb.OpenRecordset(sql, dbOpenSnapshot, dbReadOnly)
If (idinfo.recorcount = 0) Then
MsgBox
verify = False
Else
If (idinfo.Fields("密码").Value = txtpwd) Then
verifr = True
Else
MsgBox
verify = False
End If
idifo.Close
End Function
End Function
Private Sub Label3_Click()
End Sub
Private Sub Label4_Click()
End Sub
标准模块代码为:
Public id As String
Public username As String
Public coursedb As Database
Public admin As Boolean
Sub commitform(courseid, cuorsename)
With Fillfrm
.nametext.Text = username
.nametext.Locked = True
.idtxt.Text = id
.idtxt.Locked = True
.coursenametxt = coursename
.courseidtxt = xourseid
End With
Fillfrm.Show vbModal
End Sub
Sub opendb()
DBEngine.DefaultType = dbUseJet
Set coursedb = DBEngine.OpenDatabase("course.mdb", False, False)
End Sub
那位知道是怎么回事的大哥望速给我回话.