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

来源:互联网 发布:公司加密软件 破解 编辑:程序博客网 时间:2024/06/09 17:01

用户登录

**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 IfEnd SubPrivate Sub Command2_Click()    Unload MeEnd SubPrivate Sub Form_Load()    Me.Show    Form2.Hide    Me.Caption = "登录窗体"    Label1.Caption = "用户名"    Label2.Caption = "密  码"    Command1.Caption = "登陆"    Command2.Caption = "退出"    Text1.Text = ""    Text2.Text = ""End SubPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)    If MsgBox("是否关闭程序?", vbQuestion + vbYesNo, "信息提示") = vbNo Then        Cancel = True    End IfEnd Sub**form2**Private Sub Command1_Click()    Unload MeEnd SubPrivate Sub Form_Load()    Me.Caption = "客户管理系统"    Command1.Caption = "关闭系统"End SubPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)    If MsgBox("是否关闭程序", vbQuestion + vbYesNo, "信息提示") = vbNo Then        Cancel = True    End IfEnd Sub

编写程序代码获取当前程序所在目录路径

Private Sub Form_Load()    Label1.Caption = App.PathEnd Sub
0 0