具体程序如下:
Private Function checkblank() As Boolean '¼ì²é×¢²áÓû§ÐÅÏ¢ÊÇ·ñÈ«ÊäÈë
checkblank = False
Dim myStrMsg As String
myStrMsg = ""
If TxtName.Text = "" Then
myStrMsg = "请填写姓名"
TxtName.SetFocus
End If
If myStrMsg = "" Then
If TxtId.Text = "" Then
myStrMsg = " 请填写有效证件号码¡"
TxtId.SetFocus
Exit Function
End If
End If
If myStrMsg = "" Then
If TxtPassword1.Text = "" Then
myStrMsg = "请输入密码¡"
TxtPassword1.SetFocus
End If
End If
If myStrMsg = "" Then
If TxtPassword2.Text = "" Then
myStrMsg = "请确认密码¡"
TxtPassword2.SetFocus
End If
End If
If myStrMsg = "" Then
If Trim(TxtPassword1.Text) = Trim(TxtPassword2.Text) Then
TxtNote.SetFocus
Else
myStrMsg = "输入密码与之前不一致,请再次输入密码"
TxtPassword1.SetFocus
End If
End If
checkblank = True
End Function
为什么TxtName为空还是能继续输入,不会出现“请填写姓名”的提示,而且密码前后不一致,也没反应,都能输入到数据库?
Private Function checkblank() As Boolean '¼ì²é×¢²áÓû§ÐÅÏ¢ÊÇ·ñÈ«ÊäÈë
checkblank = False
Dim myStrMsg As String
myStrMsg = ""
If TxtName.Text = "" Then
myStrMsg = "请填写姓名"
TxtName.SetFocus
End If
If myStrMsg = "" Then
If TxtId.Text = "" Then
myStrMsg = " 请填写有效证件号码¡"
TxtId.SetFocus
Exit Function
End If
End If
If myStrMsg = "" Then
If TxtPassword1.Text = "" Then
myStrMsg = "请输入密码¡"
TxtPassword1.SetFocus
End If
End If
If myStrMsg = "" Then
If TxtPassword2.Text = "" Then
myStrMsg = "请确认密码¡"
TxtPassword2.SetFocus
End If
End If
If myStrMsg = "" Then
If Trim(TxtPassword1.Text) = Trim(TxtPassword2.Text) Then
TxtNote.SetFocus
Else
myStrMsg = "输入密码与之前不一致,请再次输入密码"
TxtPassword1.SetFocus
End If
End If
checkblank = True
End Function
为什么TxtName为空还是能继续输入,不会出现“请填写姓名”的提示,而且密码前后不一致,也没反应,都能输入到数据库?
解决方案 »
- API是WINDOWS编程接口,有没有系统的讲大师们设计WINDOWS API 前 完整框架的资料或书
- 请问怎样拦截文件复制、剪切等操作
- 打包后遇到的问题
- 請問网頁式的郵件,用Winsock怎么發
- 几个关于VB联接MYSQL的问题?
- 数据库乱码
- 如何使command按钮在获得焦点时没有那个虚框显示?等等
- 错误429 ActiveX控件不能创建对象
- 谁有Wise Installation System 9.0 的中文帮助?谢谢
- 如何在TEXT控件中找到指定的字符串,并得到具体的行数?
- 嵌入式SELECT查询如果没有找到所查询的数据,为什么会返回主句所指示的表中的所有数据,而不是返回空指针呢?
- 我想改变Treeview背景色
checkblank = False
Dim myStrMsg As String
myStrMsg = ""
If TxtName.Text = "" Then
myStrMsg = "请填写姓名"
TxtName.SetFocus
exit function
End If
'If myStrMsg = "" Then
If TxtId.Text = "" Then
myStrMsg = " 请填写有效证件号码¡"
TxtId.SetFocus
Exit Function
End If
'End If
'If myStrMsg = "" Then
If TxtPassword1.Text = "" Then
myStrMsg = "请输入密码¡"
TxtPassword1.SetFocus
Exit Function
End If
'End If
'If myStrMsg = "" Then
If TxtPassword2.Text = "" Then
myStrMsg = "请确认密码¡"
TxtPassword2.SetFocus
Exit Function
End If
'End If
'If myStrMsg = "" Then
If Trim(TxtPassword1.Text) = Trim(TxtPassword2.Text) Then
TxtNote.SetFocus
Else
myStrMsg = "输入密码与之前不一致,请再次输入密码"
TxtPassword1.SetFocus
Exit Function
End If
'End If
checkblank = True
End Function
checkblank = False
Dim myStrMsg As String
myStrMsg = ""
If TxtName.Text = "" Then
myStrMsg = "请填写姓名"
TxtName.SetFocus
exit function '加上这个
End If
If myStrMsg = "" Then
If TxtId.Text = "" Then
myStrMsg = " 请填写有效证件号码¡"
TxtId.SetFocus
Exit Function
End If
End If
If myStrMsg = "" Then
If TxtPassword1.Text = "" Then
myStrMsg = "请输入密码¡"
TxtPassword1.SetFocus
exit function '加上这个
End If
End If
If myStrMsg = "" Then
If TxtPassword2.Text = "" Then
myStrMsg = "请确认密码¡"
TxtPassword2.SetFocus
exit function '加上这个
End If
End If
If myStrMsg = "" Then
If Trim(TxtPassword1.Text) = Trim(TxtPassword2.Text) Then
TxtNote.SetFocus
Else
myStrMsg = "输入密码与之前不一致,请再次输入密码"
TxtPassword1.SetFocus
exit function '加上这个
End If
End If
checkblank = True
End Function
myStrMsg = "请填写姓名"
TxtName.SetFocus
End If
上面的程序段中必须加上exit function