Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i only accept numeric input in an array of text boxes?

Status
Not open for further replies.

splitsie

Programmer
Jun 29, 2001
7
0
0
AU
could someone please help?

i would like to know how to accept only numeric input in arrays of text boxes

thanks in advance the help is much appreciated
 
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
For Index = Text1.LBound To Text1.UBound
If (Not (IsNumeric(Text1(Index).Text))) Then
MsgBox "Not numeric"
Exit Sub
Text1(Index).SetFocus
Else
'when it is numeric, do something cool
End If
Next
End Sub
 
Stop them from entering.
Code:
Sub Textbox1_KeyPress (index as integer,keyascii as integer)
    If KeyAscii = 8 then exit function ' Backspace
    If Not(Chr(KeyAscii) < &quot;0&quot; or Chr(KeyAscii) > &quot;9&quot;) Then
        keyascii = 0
    End if 
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top