If txtSchool.Text =""Then MsgBox"请输入注册单位!", vbInformation CheckRegText =False txtSchool.SetFocus ExitFunction EndIf
1:len(txtSchool.Text) 要比 txtSchool.Text=""快的多。
2:为txtSchool.Text加上Trim
3:去除txtSchool的重复。
结果:
1:StringIsEmpty函数
'判断字符串的长度是否为空 PublicFunction StringIsEmpty(ByRef sString AsString) AsBoolean sString =Trim(sString) StringIsEmpty =Len(sString) =0 End Function
2:TextBoxIsEmpty函数
'文本框为空 PrivateFunction TextBoxIsEmpty(oTextBox As TextBox, sMessage AsString) AS Boolean If StringIsEmpty(oTextBox.Text) Then MsgBox sMessage, vbInformation oTextBox.SetFocus TextBoxIsEmpty =True EndIf End Function
3:最终效果
If TextBoxIsEmpty(txtPerson, "请输入注册人!") ThenExitFunction If TextBoxIsEmpty(txtConn, "请输入联系电话!") ThenExitFunction If TextBoxIsEmpty(txtSchool, "请输入注册单位!") ThenExitFunction
posted on
2006-03-09 10:32Duiker
阅读(512)
评论(0)
编辑收藏举报