CodeItBetter Programming Another VB Programming Blog

How to check whether inputed text in text box is within a specified range like 1-1000

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
'Controls - How to check whether inputed text in text box is within a specified range like 1-1000
Private Sub txtNumeric_Validate(Cancel As Boolean)
    If Not IsNumeric(txtNumeric.Text) Then
        Cancel = True
    ElseIf CDbl(txtNumeric.Text) < 1 Or CDbl(txtNumeric.Text) > 1000 Then
        Cancel = True
    End If
    If Cancel Then
        MsgBox "Please enter a number in range [1-1000]", vbExclamation
    End If
End Sub
Filed under: Controls Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.