modverifyinput.bas

来自「计算机网络与通信的知识」· BAS 代码 · 共 56 行

BAS
56
字号
Attribute VB_Name = "modVerifyInput"
'========================================================
'||         客户端输入验证模块                         ||
'========================================================


'=======================================
' 输入验证用,判断长度是否非法
' 呢称、密码、爱好不能为 0 长度
'=======================================
Public Function TxtLenError(ByVal txtCtl As TextBox, _
                            ByVal intMaxLen As Integer, _
                            ByVal strDisp) As Boolean
If Len(Trim(txtCtl.Text)) > intMaxLen Or Len(Trim(txtCtl.Text)) = 0 Then
    MsgBox strDisp + " 不允许为空,最多" + CStr(intMaxLen) + "个字符!", 16, "ICQ客户"
    txtCtl.Text = ""
    txtCtl.SetFocus
    TxtLenError = True
Else
    TxtLenError = False
End If
End Function
'===============================================================
' 校验输入的各文本中是否含有所有命令分隔符、数据库记录集字符串分隔符
' 如果含有返回 True
'===============================================================
Public Function VerifyComdDiv(ByVal txtCtl As TextBox, _
                               ByVal strDisp As String) As Boolean

If InStrComdDiv(txtCtl, strFdRd, strDisp) Or _
   InStrComdDiv(txtCtl, strFdDivRst, strDisp) Or _
   InStrComdDiv(txtCtl, strCommandDiv, strDisp) Or _
   InStrComdDiv(txtCtl, CmdResultDiv, strDisp) Then
   VerifyComdDiv = True
Else
    VerifyComdDiv = False
End If
End Function
'===============================================================
' 校验输入的各文本中是否含有指定命令分隔符、数据库记录集字符串分隔符
' 如果含有则显示出错信息,并返回True。
'===============================================================
Public Function InStrComdDiv(ByVal txtCtl As TextBox, _
                             ByVal strComdDiv As String, _
                             ByVal strDisp As String) As Boolean
If InStr(1, txtCtl.Text, strComdDiv, vbTextCompare) <> 0 Then
    MsgBox strDisp + "中不允许有" + strComdDiv + "字符!", 16, "ICQ客户"
    txtCtl.Text = ""
    txtCtl.SetFocus
    InStrComdDiv = True
Else
    InStrComdDiv = False
End If
End Function

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?