Posted: Tue Aug 19, 2008 1:59 pm Post subject: Restricitng to Numbers
Private Sub TextBox1_Change()
Dim okstop As Boolean
Dim OK_continue As Boolean
Dim mytext As String
okstop = False
Do
mytext = TextBox1.Value
If Left(mytext, 1) = "-" Then
mytext = Right(mytext, Len(mytext) - 1)
End If
If Not IsNumeric(mytext) And mytext <> "" Then
TextBox1.Value = "" 'Clears the TextBox
'Shows a message box that informs you that you typed
'something other than a number.
OK_continue = MsgBox("Please type only numbers." & _
Chr(13), vbOKOnly)
Else
okstop = True 'You typed a number in the TextBox.
End If
'Continue with the loop if you click Yes.
'Stop the loop if they typed a number in the TextBox.
Loop Until (OK_continue = vbNo) Or (okstop = True)
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum