Easy Textbox Question ? 
Author Message
 Easy Textbox Question ?

Can someone please tell me how I can determine
when a user has entered a whole word and pressed
return in a textbox. I've tried checking for vbKeyReturn
in the Text1_Change event but I guess that vb strips it
out ( I can trap other chars. )  This seems pretty basic
to me so I think that I'm missing something big here.

Any help would be appreciated.
-Eric



Mon, 08 Apr 2002 03:00:00 GMT  
 Easy Textbox Question ?


Quote:
> Can someone please tell me how I can determine
> when a user has entered a whole word and pressed
> return in a textbox. I've tried checking for vbKeyReturn
> in the Text1_Change event but I guess that vb strips it
> out ( I can trap other chars. )  This seems pretty basic
> to me so I think that I'm missing something big here.

The Return key doesn't fire a Change event, since it doesn't change the
contents of the text box.

The way to detect keypresses (including Return) is to use the KeyPress (or
KeyUp or KeyDown) event:

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
   Debug.Print Text1.Text
   Text1.Text = ""
End If
End Sub

Christina

--
C West



Mon, 08 Apr 2002 03:00:00 GMT  
 Easy Textbox Question ?
Great answer. Thanks.


Quote:


> > Can someone please tell me how I can determine
> > when a user has entered a whole word and pressed
> > return in a textbox. I've tried checking for vbKeyReturn
> > in the Text1_Change event but I guess that vb strips it
> > out ( I can trap other chars. )  This seems pretty basic
> > to me so I think that I'm missing something big here.

> The Return key doesn't fire a Change event, since it doesn't change the
> contents of the text box.

> The way to detect keypresses (including Return) is to use the KeyPress (or
> KeyUp or KeyDown) event:

> Private Sub Text1_KeyPress(KeyAscii As Integer)
> If KeyAscii = vbKeyReturn Then
>    Debug.Print Text1.Text
>    Text1.Text = ""
> End If
> End Sub

> Christina

> --
> C West




Mon, 08 Apr 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ..easy textbox question from a newbie

2. easy textbox question

3. EASY EASY EASY question

4. help easy easy question

5. easy filecopy question...but maybe not so easy

6. easy textbox-problem

7. Should be an easy one - textboxes

8. easy I hope: how to copy and paste a textbox control (designtime)

9. easy question

10. Easy Loops question?

11. bitmaps, easy question

12. Public functions, easy question

 

 
Powered by phpBB® Forum Software