导航:首页 > 源码编译 > 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编译账号和密码检验程序相关的资料

热点内容
学校论文答辩源码 浏览:60
rp在单片机中 浏览:172
linux软件运行命令 浏览:352
stcid加密程序 浏览:134
把解压包子放到水里 浏览:280
phpmongodb连接池 浏览:940
日本解压捏泡泡纸 浏览:115
环保参比算法 浏览:407
解压中的删掉是什么意思 浏览:763
王牌竞速什么时候能停止维修服务器 浏览:485
pdf阅读器官方 浏览:84
程序员那么爱心 浏览:304
字符a经过md5加密 浏览:416
绿色的小蝴蝶是个什么app 浏览:14
python编程输入数字输出年月日英文 浏览:627
程序员枪手 浏览:748
gm28服务器怎么设置 浏览:543
饿了么网站源码 浏览:332
天选程序员真的有用吗 浏览:918
微信登录服务器什么意思 浏览:353