Thread: Stay in TextBox
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mark S.[_2_] Mark S.[_2_] is offline
external usenet poster
 
Posts: 1
Default Stay in TextBox

Add the text box Exit event to your form:

Private Sub TextBox1_Exit(ByVal Cancel As
MSForms.ReturnBoolean)
If (TextBox1.Text = "invalid input") Then
Cancel = True
End If
End Sub

If you set Cancel to true the cursor is not moved out of
the text box.

-----Original Message-----
In a Form I have a TextBox. When I leave the textBox, I

run a validation of the input.
What I need is to stay in the TextBox, whenever the

validation goes wrong.

In another way whenever the user tab out of the TextBox,

or click on another TextBox in the Form, the Curser must
jump back... or even better... not leave the actual
TextBox.

How to???
.