Article ID: 158749
Article Last Modified on 10/11/2006
Private Sub TextBox1_Change()
Dim okstop As Boolean
Dim yesno_continue As Boolean
Dim mytext As String
okstop = False
Do
mytext = TextBox1.Value
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.
yesno_continue = MsgBox("Please type only numbers." & _
Chr(13) & "Continue?", vbYesNo)
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 (yesno_continue = vbNo) Or (okstop = True)
End Sub
Sub Data_Validate()
UserForm1.Show 'Displays the custom UserForm.
End Sub
Additional query words: XL97 user form
Keywords: kbdtacode kbprogramming KB158749