图5.1 登录界面
程序代码如下:
Dim cnt As Integer
Dim Conn As New ADODB.Connection
Private Sub command1_Click()
Dim sql As String
Dim rs_login As New ADODB.Recordset
If Trim(Text1.Text) = "" Then
MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Else
sql = "select * from登录界面 where 用户名='" & Text1.Text & "'"
rs_login.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_login.EOF = True Then
MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Else
If Trim(rs_login.Fields(1)) = Trim(Text2.Text) Then
userID = Text1.Text
rs_login.Close
Unload Me
主界面.Show
Else
MsgBox "密码不正确", vbOKOnly + vbExclamation, ""
Text2.SetFocus
End If
End If
End If
cnt = cnt + 1
If cnt = 3 Then
Unload Me
End If
Exit Sub
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim connectionstring As String
connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & App. Path & "设备管理系统.mdb " & "Persist Security Info=False"
conn.Open connectionstring
cnt = 0
End Sub
5.2 主界面
主界面主要采用两种:菜单和工具栏。如图5.2所示