Excel VBA 编辑一个登陆窗口
1、设计窗体
窗体为标志label3个;按钮button3个;文本域textbox2个;并为响应的组件
设置tooltip工具提示。背景图片一张,使用loadpicture()函数载入图片
设置图片自动填满,label背景为空,即0。
Private Sub UserForm_Activate()
Image1.Visible = True
Image1.Picture = LoadPicture("C:\Users\jyjh\Desktop\main.jpg")
Image1.AutoSize = False
Image1.PictureSizeMode = fmPictureSizeModeStretch
Label1.BackStyle = 0
Label2.BackStyle = 0
Label3.BackStyle = 0
End Sub
2、设置按钮功能
Private Sub CommandButton1_Click()
If TextBox1.Text = "admin" And TextBox2.Text = "123" Then
UserForm1.Hide
Application.Visible = True
MsgBox "Login_successfully! "
Else
MsgBox "Error,please try again!"
End If
Private Sub CommandButton2_Click()
ThisWorkbook.Close
End Sub
password文本域设置为passwchar *用于隐藏输入字符。
3、模拟打开登录:
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:30
阅读量:71
阅读量:63
阅读量:76
阅读量:20