您的位置:首页 > 编程语言 > VB

VB程序学习代码记录20160722(2)

2016-07-22 22:49 423 查看
用户登录

**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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: