| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 417 人关注过本帖
标题:非数字登陆问题,请指点一下?
只看楼主 加入收藏
hsy1217
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2006-5-7
收藏
 问题点数:0 回复次数:0 
非数字登陆问题,请指点一下?

我是初学者,我在做一个登陆界面,要求不能是非数字型用户名。我做2中都有缺陷。
第一种,是用循环只要输入非数字他都会应为字符的长度循环6次。
Private Sub Command1_Click()
Dim i As String, a As String, b As String
Dim str1 As String, c As Integer
str1 = Text1.Text
For c = 1 To Len(str1)
If Not IsNumeric(Mid(str1, c, 1)) Then
i = MsgBox("帐号中出现非数字字符" + Chr(13) + Chr(10) + "请重新输入!", 0 + 16 + 0, "输入帐号")
End If
Next c

a = (Text1.Text)
b = (Text2.Text)
If a <> "123456" Then
i = MsgBox("帐号错误" + Chr(13) + Chr(10) + "请重新输入", 1 + 16 + 0, "请输入帐号")
Text1.Text = ""
Text1.SetFocus
ElseIf b <> "vb6" Then
i = MsgBox("密码错误", 1 + 48 + 0, "请输入密码")
Text2.Text = ""
Text2.SetFocus
ElseIf a = "123456" And b = "vb6" Then
Form1.Hide
Form2.Show
End If
End Sub

Private Sub Command2_Click()
End
End Sub

Private Sub Text1_Change()
Text1.MaxLength = 6
End Sub

Private Sub Text2_Change()
Text2.MaxLength = 4
Text2.PasswordChar = "*"
End Sub

第二种,不管输入数字还是非数字都要经过第一段程序,而且帐号密码都对都进不去。
Private Sub Command1_Click()
Dim i As String, a As String, b As String
Dim str1 As String, c As Integer
Dim d As Boolean
If Not IsNumeric(d) = False Then
i = MsgBox("帐号中出现非数字字符" + Chr(13) + Chr(10) + "请重新输入!", 0 + 16 + 0, "输入帐号")
Text1.Text = ""
End If
a = (Text1.Text)
b = (Text2.Text)
If a <> "123456" Then
i = MsgBox("帐号错误" + Chr(13) + Chr(10) + "请重新输入", 1 + 16 + 0, "请输入帐号")
Text1.Text = ""
Text1.SetFocus
ElseIf b <> "vb6" Then
i = MsgBox("密码错误", 1 + 48 + 0, "请输入密码")
Text2.Text = ""
Text2.SetFocus
ElseIf a = "123456" And b = "vb6" Then
Form1.Hide
Form2.Show
End If
End Sub

Private Sub Command2_Click()
End
End Sub

Private Sub Text1_Change()
Text1.MaxLength = 6
End Sub

Private Sub Text2_Change()
Text2.MaxLength = 4
Text2.PasswordChar = "*"
End Sub
请高手指点,请说详细一点,我是新手好多都不太懂。

搜索更多相关主题的帖子: 数字 登陆 
2006-05-13 23:25
快速回复:非数字登陆问题,请指点一下?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016377 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved