小弟在本站下了一个例子,研究了一下登录窗体,可是这些代码我不是很懂,在这里有劳大家教教我,不弟很愚。。。。感谢了!
Option Compare Database
Option Explicit(1。这里是不是定义全局变量?)Dim i As Integer
Dim img(9) As Image
Private Sub Form_AfterUpdate() (2。这是什么函数?) Dim rs As Recordset
Dim strSQL As String
End Sub
Private Sub Form_Load()
On Error GoTo err (3。这句是什么意思?) Me.命令2.Visible = False
Me.命令3.Visible = False
Me.密码 = ""
Me.用户名 = ""
Me.用户名.SetFocus(4。这句是什么意思)
Set img(0) = Me.imgLine1
Set img(1) = Me.imgLine2
Set img(2) = Me.imgLine3
Set img(3) = Me.imgLine4
Set img(4) = Me.imgLine5
Set img(5) = Me.imgLine6
Set img(6) = Me.imgLine7
Set img(7) = Me.imgLine8
Set img(8) = Me.imgLine9
Set img(9) = Me.imgLine10
Me.TimerInterval = 200
Exit Sub
err: (5。这一段是什么意思?) MsgBox err.Number & err.Description
End Sub
Private Sub Form_Timer() (6。这是什么函数?) If i > 9 Then i = 0
Call showLineImg(i)
i = i + 1
End Sub
Private Function showLineImg(ByVal CurrentImgNo As Integer) (7。这个是什么) Dim c As Integer
For c = 0 To 9
If CurrentImgNo = c Then
img(c).Visible = True
Else
img(c).Visible = False
End If
Next c
End Function
Private Sub 命令1_Click()
On Error GoTo Err_命令1_Click (7.这句是什么意思)
Dim stLinkCriteria As String
Const Maxlogtimes As Integer = 2
Static intlogtimes As Integer
intlogtimes = intlogtimes + 1
If Me.密码 = DLookup("pass", "登陆表格", "user=" & "'" & 用户名 & "'") And Me.用户名 <> "" Then
DoCmd.Close
DoCmd.OpenForm "编辑窗口"
ElseIf [密码] = "" And Me.用户名 = "" Then
MsgBox "请输入用户名或密码!谢谢!", vbCritical, "错误提示"
Me.用户名 = ""
Me.密码 = ""
Me.用户名.SetFocus (9.这句是什么意思)
If intlogtimes > Maxlogtimes Then
MsgBox "你没有本系统的使用权限!", vbInformation, "系统警告"
DoCmd.Quit
End If
Else
MsgBox "用户名或密码错误!请重新输入!", vbCritical, "错误提示"
Me.密码 = ""
Me.用户名 = ""
Me.用户名.SetFocus
If intlogtimes > Maxlogtimes Then
MsgBox "你没有本系统的使用权限!", vbInformation, "系统警告"
DoCmd.Quit
End If
End If
Exit_命令1_Click:
Exit Sub
Err_命令1_Click:
MsgBox err.Description
Resume Exit_命令1_Click
End Sub
Private Sub 命令2_Click()
On Error GoTo Err_命令2_Click
DoCmd.Close
DoCmd.OpenForm "修改密码"
Exit_命令2_Click:
Exit Sub
Err_命令2_Click:
MsgBox err.Description
Resume Exit_命令2_Click
End Sub
Private Sub 命令3_Click()
On Error GoTo Err_命令3_Click
DoCmd.Close
DoCmd.OpenForm "帮助窗口"
Exit_命令3_Click:
Exit Sub
Err_命令3_Click:
MsgBox err.Description
Resume Exit_命令3_Click
End Sub
Private Sub 命令4_Click()
On Error GoTo Err_命令4_Click
MsgBox "如果阁下需要使用本系统,请与作者联系!", vbInformation, "系统提示"
DoCmd.Quit
Exit_命令4_Click:
Exit Sub
Err_命令4_Click:
MsgBox err.Description
Resume Exit_命令4_Click
End Sub
Private Sub 命令5_Click()
On Error GoTo Err_命令5_Click
Me.命令2.Visible = True
Me.命令3.Visible = True
Me.用户名.SetFocus
Me.命令5.Visible = False
Exit_命令5_Click:
Exit Sub
Err_命令5_Click:
MsgBox err.Description
Resume Exit_命令5_Click
End Sub
[此贴子已经被作者于2004-2-23 14:25:20编辑过]
|