导航:首页 > 源码编译 > vb编译账号和密码检验程序

vb编译账号和密码检验程序

发布时间:2023-01-09 02:33:38

㈠ VB程序编写账号和密码的验证程序

PrivateSubCommand1_Click()
IfIsNumeric(Text1.Text)AndLen(Text1.Text)=6AndText2.Text="good"Then
MsgBox"输入正确,验证通过",vbOKCancel,"验证通过"
Else
IfMsgBox("账号或密码错误",vbRetryCancel,"验证错误")=vbRetryThen
Text1.Text=""
Text2.Text=""
Text1.SetFocus
Else
End
EndIf
EndIf

EndSub

PrivateSubForm_Load()
Text1.PasswordChar="*"

EndSub

㈡ 用VB编写“密码校验”程序的设计

完整代码如下,初始化都已经做好啦,添加控件试试吧:

Dim NCount As Integer

Private Sub Form_Load()
'初始化控件信息
Caption = "密码校验"
Label1.Caption = "请输入密码:"
Text1.Text = ""
Label2.ForeColor = &HFF&
Label2.Alignment = 2
Label2.FontName = "宋体"
Label2.FontSize = 15.75
Label2.AutoSize = True
Label2.Visible = False
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If Len(Text1.Text) > 6 And KeyAscii <> 8 And KeyAscii <> 13 Then
KeyAscii = 0
End If
If KeyAscii = 13 And Text1.Text = "1234567" Then
Label2.Caption = "欢迎光临!"
Label2.Visible = True
ElseIf KeyAscii = 13 Then
If NCount <> 1 Then
Label2.Visible = True
Label2.Caption = "密码不符,请再输入一遍!"
Text1.Text = ""
NCount = NCount + 1
Else
Label2.Visible = True
Label2.Caption = "非法用户,请推出程序!"
Text1.Text = ""
Text1.Enabled = False
End If
End If
End Sub

㈢ 用VB语言编制一个帐号与密码的检验程序

Option Explicit
Const MaxLogTimes As Integer = 3

Private Sub cmdCancel_Click()
Dim intResult As Integer
'请求用户确认是否真的退出系统登录
intResult = MsgBox("你选择了退出系统登录,退出将不能启动管理系统!" & vbCrLf & "是否真的退出?", vbYesNo, "登录验证")
If intResult = vbYes Then End '根据用户选择结束应用程序
End Sub

Private Sub cmdOK_Click()
Static intLogTimes As Integer '用于保存用户请求验证的次数
Dim intChecked As Integer, strName As String, strPassword As String
intLogTimes = intLogTimes + 1 '计算登录次数
If intLogTimes > MaxLogTimes Then
'超过允许的登录次数,显示提示信息
MsgBox "你已经超过允许验证次数!" & vbCr & "应用程序将结束!", vbCritical, "登录验证"
End '结束应用程序
Else '进一步验证登录信息的合法性
strName = Trim(txtUserName.Text) '获得输入的用户名
strPassword = Trim(txtPassWord.Text) '获得输入的口令
'检验用户名和口令的合法性,并根据检验返回值执行相应的操作
if(strName ="123456")
if(strPassword="VB6") '口令正确
Unload Me '卸载登录窗体
MsgBox "登录成功,将启动系统程序!", vbInformation, "登录验证"
'通常在此放置显示系统主窗体的语句,例如
'frmMain.Show
else
MsgBox "口令错误,请重新输入!", vbCritical, "登录验证"
txtPassWord.Text = ""
txtPassWord.SetFocus
end if
else '用户不是系统用户
MsgBox "<" & strName & ">不是系统用户,请检查用户名输入是否正确!", vbCritical, "登录验证"
txtUserName.Text = ""
txtPassWord.Text = ""
txtUserName.SetFocus
End If
End If
End Sub

'这是你要的重试 我觉得很没有必要
Private Sub cmdReset_Click()
txtPassWord.Text = ""
txtPassWord.SetFocus
End Sub

说明:
1.账号密码一般是通过数据库调用的,这个程序只是用于娱乐或者测试
2.密码框输出显示请在VB的密码框属性设置里更该,设password为*即可
3.好好读读代码,你就明白代码怎么用了

阅读全文

与vb编译账号和密码检验程序相关的资料

热点内容
c语言常用算法pdf 浏览:960
编程如何让画面动起来 浏览:865
大龄女程序员未来发展 浏览:976
数学书籍pdf 浏览:506
加密门禁卡写入成功无法开门 浏览:464
齿轮传动pdf 浏览:52
alpinelinux 浏览:150
手机端app的扫码功能在哪里 浏览:227
少儿编程中小班英语教案 浏览:452
锁屏密码加密手机怎么解除 浏览:205
linuxlostfound 浏览:135
征途服务器ip地址 浏览:330
git提交代码命令行 浏览:165
什么叫浏览器服务器结构 浏览:157
于谦聊天哪个app 浏览:449
小鹏汽车nlp算法工程师薪资 浏览:881
代码加密与隐藏 浏览:649
fordfulkerson算法 浏览:352
京东热app在哪里可以下载 浏览:877
彩报图书app哪个好 浏览:303