text box that only accepts numbers 
Author Message
 text box that only accepts numbers

I'm sure this will work with VB5 - use the Validate Event
as per this example:

Private Sub txtTextBox_Validate(KeepFocus As Boolean)
If Not IsNumeric(txtTextBox.Text) Or Not (Val
(txtTextBox.Text) > -1 _
    And Val(txtTextBox.Text) < 32001) Then
    KeepFocus = True
    MsgBox "You must enter a number between 1 and 32,000!"

    txtTextBox.Text = ""
    txtTextBox.SetFocus
End If
End Sub

This insures that the Text in the TextBox is a number
between 0 and 32000

**** Posted from RemarQ - http://www.*-*-*.com/ - Discussions Start Here (tm) ****



Thu, 15 Nov 2001 03:00:00 GMT  
 text box that only accepts numbers
There isn't a validate event in VB5.

Mike

Quote:

>I'm sure this will work with VB5 - use the Validate Event
>as per this example:

>Private Sub txtTextBox_Validate(KeepFocus As Boolean)
>If Not IsNumeric(txtTextBox.Text) Or Not (Val
>(txtTextBox.Text) > -1 _
>    And Val(txtTextBox.Text) < 32001) Then
>    KeepFocus = True
>    MsgBox "You must enter a number between 1 and 32,000!"

>    txtTextBox.Text = ""
>    txtTextBox.SetFocus
>End If
>End Sub

>This insures that the Text in the TextBox is a number
>between 0 and 32000

>**** Posted from RemarQ - http://www.remarq.com - Discussions Start Here

(tm) ****


Fri, 16 Nov 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. text box that only accepts numbers

2. Only Accept Numbers in Text Box

3. Text box doesn't accept changes...

4. Text box not accepting keystrokes

5. Allowing ONLY text to be typed in my text box - NO NUMBERS

6. Allowing ONLY text to be typed in my text box - NO NUMBERS

7. Exporting a 3 decimal number to text file produces trunc 2 decimal text number

8. Text box text on new page text box

9. Number Keypad Values Not accepted as Numieric

10. Force Textbox to accept only whole numbers

11. callbyname accepting varying number of arguments

12. How do I get a Textbox to only accept numbers

 

 
Powered by phpBB® Forum Software