what i want is to put a range in the textboxes like 1-100 and will not accept if it is greater than 100
or a negative number...

hoping for your response...

Recommended Answers

All 4 Replies

its simple
use the following code on textbox lostfocus event

If Val(Text1.Text) > 100 Then
MsgBox "Invalid "
Text1.SetFocus
End If

Hi,

In Property pages of Text1 .. MaxLength = 3
write this code, in Validate Event of textbox

Private Sub Text1_Validate(Cancel As Boolean)
    If Val(Text1.Text) > 0 And Val(Text1.Text) <=100 Then
    Else
        Cancel = True
    End If
End Sub

Regards
Veena

If you just want the number entered...use a NumericUpDown control, it will allow you to set a valid range of values

A MaskedEdit Control will restrict your input to numbers and you can specify a certain number of digits, and you can specify formatting as well.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.