怎么用VB设计一个登陆界面?
2个回答
展开全部
1.首先添加2个label控件,一个caption为用户名,一个为密码然后分别在2个label控件后面添加一个text控件,
2.将text的text属性设置为空再添加2个button按钮,一个名为登陆,一个名为取消简要代码如下:
private sub text2_change() sswordchar="*"end subprivate sub button1_click()if text1.text="text" and text2.text="123456" then '这里写验证代码... '通过验证后要干么elsemsgbox("用户名或者密码不正确!")end if end subprivate sub button2_click()endend sub
展开全部
Private Sub Command1_Click()
Static i As Integer
If Text1.Text = "" And Text2.Text = "" Then
MsgBox "请输入用户名和密码", vbOKOnly, "提示"
Text1.SetFocus
Exit Sub
End If
If Text1.Text = "admin" And Text2.Text = "admin" Then
MsgBox "用户名密码正确", vbOKOnly, "提示"
i = 0
Else
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Text1.SetFocus
If i < 3 Then
MsgBox "用户名或密码错误,请重新输入", vbOKOnly, "提示"
i = i + 1
End If
If i = 3 Then
MsgBox "输入3次错误用户名或密码,程序将退出", vbOKOnly, "提示"
Unload Me
End If
End If
End Sub
Private Sub Form_Load()
Label1.Caption = "用户名"
Label2.Caption = "密 码"
Text1.Text = ""
Text2.Text = ""
Text2.PasswordChar = "*"
Command1.Caption = "确定"
End Sub
Static i As Integer
If Text1.Text = "" And Text2.Text = "" Then
MsgBox "请输入用户名和密码", vbOKOnly, "提示"
Text1.SetFocus
Exit Sub
End If
If Text1.Text = "admin" And Text2.Text = "admin" Then
MsgBox "用户名密码正确", vbOKOnly, "提示"
i = 0
Else
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Text1.SetFocus
If i < 3 Then
MsgBox "用户名或密码错误,请重新输入", vbOKOnly, "提示"
i = i + 1
End If
If i = 3 Then
MsgBox "输入3次错误用户名或密码,程序将退出", vbOKOnly, "提示"
Unload Me
End If
End If
End Sub
Private Sub Form_Load()
Label1.Caption = "用户名"
Label2.Caption = "密 码"
Text1.Text = ""
Text2.Text = ""
Text2.PasswordChar = "*"
Command1.Caption = "确定"
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询