下面这个程序是一个用户登陆的判断。有2个文本框和一个cmd控件,其中userindb是一个执行SQL语言的函数,参数1是SQL语句,参数2是指定列参数,比如:sqlstr = "select * from minisysmanage_inf where 管理员ID='" + IDText.Text + "'"
userindb(sqlstr, 2)
是读取sqlstr返回记录中第2列的数据
sysID,syspas,trytime是全局变量
如果正常登陆没有问题,但是我如果连续错误登陆好几次就会出现0x7788157f指令引用的0x03ddfffc内存。该内存不能为read这样的错误。这个问题很棘手,但是如果放着可能会导致后面的程序出现莫名的错误。
Private Sub cmdok_Click()
Dim sqlstr As String
If IDText.Text = "" Then
MsgBox "请输入次级服务器管理员ID", , "登陆错误"
Exit Sub
End IfIf Pastext.Text = "" Then
MsgBox "请输入次级服务器管理员密码", , "登陆错误"
Exit Sub
End If
If trytime > 3 Then
MsgBox "错误输入三次,系统将强行退出!", , "警告!"
Unload Me
userloading.Show
Exit Sub
End If
sqlstr = "select * from minisysmanage_inf where 管理员ID='" + IDText.Text + "'"
If userindb(sqlstr, 2) = False Then
MsgBox "此用户不存在,请重新输入", , "警告"
trytime = trytime + 1
Else
If Pastext.Text <> trimstr(colvol) Then
MsgBox "密码错误,请重新输入", , "警告!"
trytime = trytime + 1
Exit Sub
Else
sysID = IDText.Text
syspas = Pastext.Text
minimanager_manage.Show
Unload Me
End If
End If
End SubPrivate Sub Form_Load()
trytime = 1
End SubPrivate Sub IDText_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Pastext.SetFocus
Exit Sub
End If
If check_ID_pas(KeyAscii) = False Then
MsgBox "合法的ID是大、小写字母和下划线", , "警告"
KeyAscii = 0
End If
End Sub
Private Sub Pastext_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdok.SetFocus
Exit Sub
End If
If check_ID_pas(KeyAscii) = False Then
MsgBox "合法的pas是大、小写字母和下划线", , "警告"
KeyAscii = 0
End If
End Sub
userindb(sqlstr, 2)
是读取sqlstr返回记录中第2列的数据
sysID,syspas,trytime是全局变量
如果正常登陆没有问题,但是我如果连续错误登陆好几次就会出现0x7788157f指令引用的0x03ddfffc内存。该内存不能为read这样的错误。这个问题很棘手,但是如果放着可能会导致后面的程序出现莫名的错误。
Private Sub cmdok_Click()
Dim sqlstr As String
If IDText.Text = "" Then
MsgBox "请输入次级服务器管理员ID", , "登陆错误"
Exit Sub
End IfIf Pastext.Text = "" Then
MsgBox "请输入次级服务器管理员密码", , "登陆错误"
Exit Sub
End If
If trytime > 3 Then
MsgBox "错误输入三次,系统将强行退出!", , "警告!"
Unload Me
userloading.Show
Exit Sub
End If
sqlstr = "select * from minisysmanage_inf where 管理员ID='" + IDText.Text + "'"
If userindb(sqlstr, 2) = False Then
MsgBox "此用户不存在,请重新输入", , "警告"
trytime = trytime + 1
Else
If Pastext.Text <> trimstr(colvol) Then
MsgBox "密码错误,请重新输入", , "警告!"
trytime = trytime + 1
Exit Sub
Else
sysID = IDText.Text
syspas = Pastext.Text
minimanager_manage.Show
Unload Me
End If
End If
End SubPrivate Sub Form_Load()
trytime = 1
End SubPrivate Sub IDText_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Pastext.SetFocus
Exit Sub
End If
If check_ID_pas(KeyAscii) = False Then
MsgBox "合法的ID是大、小写字母和下划线", , "警告"
KeyAscii = 0
End If
End Sub
Private Sub Pastext_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdok.SetFocus
Exit Sub
End If
If check_ID_pas(KeyAscii) = False Then
MsgBox "合法的pas是大、小写字母和下划线", , "警告"
KeyAscii = 0
End If
End Sub
解决方案 »
- 关于open文件后,get文件数据到string里面出错得问题。
- 如何截去数组前面的几个元素?
- 获取服务器上数据库的表名问题,在线等待!
- 简单游戏外挂开发,up、提供思路者有分!
- 关于用vb来实现sql数据库里面的表,转换成excel文件的程序,不能运行,急等待
- 打印卡片问题。
- ado的一个问题
- 如何触发ctrl+DD 事件
- 请问如何得到剪贴板中图像数据的长度?请给出代码。
- 一个不小的问题!
- 求助!!关于drive和dir的!!(急!!!)
- 从Access数据库查找合适的记录后生成一个EXCEL文件并加上打开密码后自动以当前Outlook Express的默认帐户发送给一个电子邮件地址。怎么写
MsgBox "错误输入三次,系统将强行退出!", , "警告!"
Unload Me
userloading.Show
Exit Sub
End If该写成:
If trytime > 3 Then
MsgBox "错误输入三次,系统将强行退出!", , "警告!"
userloading.Show
Unload Me
Exit Sub
End If同理,你要在所有的unload me 右面都加上一句 exit sub
即:
Unload Me
Exit Sub你试试看好了。
我trytime是在模块里定义的,至于东西没卸载干净,我想在刚开始的时候装载的东西不多,应该都卸干净拉,不过我还是在看看。
向你们敬礼!!!
Dim trytime As IntegerPrivate Sub cmdcancel_Click()userloading.Show
Unload Me
End SubPrivate Sub cmdok_Click()
Dim sqlstr As String
If IDText.Text = "" Then
MsgBox "请输入主服务器管理员ID", , "登陆错误"
Exit Sub
End IfIf Pastext.Text = "" Then
MsgBox "请输入主服务器管理员密码", , "登陆错误"
Exit Sub
End If
If trytime > 3 Then
MsgBox "错误输入三次,系统将强行退出!", , "警告!"
End
End If
sqlstr = "select * from sysmanage_inf where sysmanager_ID='" & IDText.Text & "'"
If userindb(sqlstr, 2) = False Then
MsgBox "此用户不存在,请重新输入", , "警告"
trytime = trytime + 1
If trytime > 3 Then
MsgBox "您已经三次尝试进入本系统,均不成功,系统将关闭"
End Else
Exit Sub
End If
End If
'判断密码是否正确
If trimstr(colvol) <> Pastext.Text Then
MsgBox "密码错误"
trytime = trytime + 1
If trytime >= 3 Then
MsgBox "您已经三次尝试进入本系统,均不成功,系统将关闭"
End
Else
Exit Sub
End If
End If
'登录成功,将当前用户的信息保存在sysID,syspas中
sysID = IDText.Text
syspas = Pastext.Text
sysmanager_manage.Show
Unload Me
End SubPrivate Sub Form_Load()
trytime = 1
End SubPrivate Sub IDText_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Pastext.SetFocus
Exit Sub
End If
If check_ID_pas(KeyAscii) = False Then
MsgBox "合法的ID是大、小写字母和下划线", , "警告"
KeyAscii = 0
End If
End SubPrivate Sub Pastext_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdok.SetFocus
Exit Sub
End If
If check_ID_pas(KeyAscii) = False Then
MsgBox "合法的pas是大、小写字母和下划线", , "警告"
KeyAscii = 0
End If
End Sub