in something like...
if txtBox.text = "" then
msgbox "enter something in the textbox please"
how would i change that if I only wanted numerical data inputted?
thanks
Printable View
in something like...
if txtBox.text = "" then
msgbox "enter something in the textbox please"
how would i change that if I only wanted numerical data inputted?
thanks
This will also eliminate Cut n Paste problems.
And....
Using the Validate Event prevents the TextBox loosing focus
before the validation is conducted (which would result in invalid
data remaining in the TextBox.
However, whilst a user can temporaraly enter invalid data, when
they move to another control they are alerted, and sent
back to the TextBox until a valid entry is made.
VB Code:
Private Sub Text1_Validate(Cancel As Boolean) For i = 1 To Len(Text1.Text) If Not IsNumeric(Mid(Text1.Text, i, 1)) Then MsgBox "Invalid Charater, Numbers Only please" Text1.SelStart = i - 1 Text1.SelLength = 1 Text1.SetFocus Cancel = True Exit Sub End If Next End Sub
Here is a control that I wrote called NumberBox. It is essentially a textbox that limits input to numbers. It also has the following new properties.
CanBeNegative
CanHaveDecimals
MaxDecimals
thanks guys, just what i was lookin for :)