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

用户登录

**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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值