VB6.0中设置Text的输入函数。

来源:互联网 发布:自学考试网络助学 编辑:程序博客网 时间:2024/05/09 21:49
Public Sub MaxAndNumeric(txt As TextBox, x As Boolean)
    If IsNumeric(txt) = False Or txt.Text = "" Then                       '判断输入是否为数值,是否为空
       txt.Text = ""
       Exit Sub
    End If
    If x = True Then
       If Int(Val(txt.Text)) > 59 Or Int(Val(txt.Text)) < 0 Then         '判断输入数值是否在0-59之间
          txt.Text = ""
       End If
    ElseIf x = False Then
       If Int(Val(txt.Text)) > 24 Or Int(Val(txt.Text)) < 0 Then          '判断输入数值是否在0-24之间
          txt.Text = ""
       End If
    End If
End Sub