用户登录
**form1:**
Private Sub Command1_Click()
If Text1.Text <> "" Then
If Text2.Text = "" Then
MsgBox "请输入密码!"
Exit Sub
Else
Form2.Show
Me.Hide
End If
Else
MsgBox "请输入用户名!"
Exit Sub
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Me.Show
Form2.Hide
Me.Caption = "登录窗体"
Label1.Caption = "用户名"
Label2.Caption = "密 码"
Command1.Caption = "登陆"
Command2.Caption = "退出"
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If MsgBox("是否关闭程序?", vbQuestion + vbYesNo, "信息提示") = vbNo Then
Cancel = True
End If
End Sub
**form2**
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_Load()
Me.Caption = "客户管理系统"
Command1.Caption = "关闭系统"
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If MsgBox("是否关闭程序", vbQuestion + vbYesNo, "信息提示") = vbNo Then
Cancel = True
End If
End Sub
编写程序代码获取当前程序所在目录路径
Private Sub Form_Load()
Label1.Caption = App.Path
End Sub