I Feel Embarrassed To Ask This Question 
Author Message
 I Feel Embarrassed To Ask This Question

All

this must be one of the easiest questions for you guys....

I know the character number for enter is 13, but i how do i incorporate this
into an if...

If ("Enter key pressed") then

    msgbox("mark is {*filter*}at VB")

end if

i have tried quite a few things but just cannot seem to get it to work!!

--
--
Mark Fowkes



Sat, 13 Apr 2002 03:00:00 GMT  
 I Feel Embarrassed To Ask This Question
Write the following code in the Keypress event of the command button or
textbox button

Private Sub button_KeyPress()

If keyascii = 13 then
Msgbox "Mark is {*filter*}in VB"
End If

End Sub

* Sent from RemarQ http://www.*-*-*.com/ The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



Sat, 13 Apr 2002 03:00:00 GMT  
 I Feel Embarrassed To Ask This Question
Mark,

Private Sub Text1_KeyPress(KeyAscii As Integer)

    If (KeyAscii = 13) Then
        MsgBox "Keep asking questions and you will soon be a guru"
    End If

End Sub

Quote:

> All

> this must be one of the easiest questions for you guys....

> I know the character number for enter is 13, but i how do i incorporate this
> into an if...

> If ("Enter key pressed") then

>     msgbox("mark is {*filter*}at VB")

> end if

> i have tried quite a few things but just cannot seem to get it to work!!

> --
> --
> Mark Fowkes



Sat, 13 Apr 2002 03:00:00 GMT  
 I Feel Embarrassed To Ask This Question

Mark,

Private Sub Text1_KeyPress(KeyAscii As Integer)

    If (KeyAscii = 13) Then
        MsgBox "Keep asking questions and you will soon be a guru"
    End If

End Sub  

Quote:

> All

> this must be one of the easiest questions for you guys....

> I know the character number for enter is 13, but i how do i incorporate this
> into an if...

> If ("Enter key pressed") then

>     msgbox("mark is {*filter*}at VB")

> end if

> i have tried quite a few things but just cannot seem to get it to work!!

> --
> --
> Mark Fowkes



Sat, 13 Apr 2002 03:00:00 GMT  
 I Feel Embarrassed To Ask This Question
Why dont any of the above work?????

i we all sure that 13 is enter?

mad.....

anyone else?
--
--
Mark Fowkes

- What I am Now Reading!
- When The Wind Blows, James Patterson
-
http://www.*-*-*.com/
26-7854878-1469213

_________________________________________________

                     Final Year Bsc Computing
                De-Montfort University Leicester


                           ICQ No: 30486452

                              Web Page:
      http://www.*-*-*.com/
_________________________________________________


Quote:

> Mark,

> Private Sub Text1_KeyPress(KeyAscii As Integer)

>     If (KeyAscii = 13) Then
>         MsgBox "Keep asking questions and you will soon be a guru"
>     End If

> End Sub


> > All

> > this must be one of the easiest questions for you guys....

> > I know the character number for enter is 13, but i how do i incorporate
this
> > into an if...

> > If ("Enter key pressed") then

> >     msgbox("mark is {*filter*}at VB")

> > end if

> > i have tried quite a few things but just cannot seem to get it to work!!

> > --
> > --
> > Mark Fowkes



Sat, 13 Apr 2002 03:00:00 GMT  
 I Feel Embarrassed To Ask This Question

Quote:
> Why dont any of the above work?????

It should work.  Maybe something else is catching the <cr> before your
function.  Do you have any buttons with the default attribute set to true?

Quote:
> i we all sure that 13 is enter?

Yes.

Quote:

> mad.....

> anyone else?

You might want to try the keydown event:

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)

    If (KeyCode = vbEnter) Then
        MsgBox "Keep experimenting with events and you will soon be a guru"
    End If

End Sub

To make it work anywhere on the form put it in the form's keydown event and
set the keypreview property of the form to true.



Sat, 13 Apr 2002 03:00:00 GMT  
 I Feel Embarrassed To Ask This Question


Quote:
> Why dont any of the above work?????

The enter key is not trapped in the keypress event.

The Keydown event does trap it however.

eg:

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
     If keycode = vbkeyreturn then
           msgbox "Tada"
     End If
End Sub

Note that vbKeyReturn is the constant for the enter key.  It is usually
a better idea to use these constants as it makes debugging much easier.

Quote:

> i we all sure that 13 is enter?

> mad.....

> anyone else?
> --
> --
> Mark Fowkes

> - What I am Now Reading!
> - When The Wind Blows, James Patterson
> -

http://www.*-*-*.com/
-1/0

Quote:
> 26-7854878-1469213

> _________________________________________________

>                      Final Year Bsc Computing
>                 De-Montfort University Leicester


>                            ICQ No: 30486452

>                               Web Page:
>       http://www.*-*-*.com/
> _________________________________________________



> > Mark,

> > Private Sub Text1_KeyPress(KeyAscii As Integer)

> >     If (KeyAscii = 13) Then
> >         MsgBox "Keep asking questions and you will soon be a guru"
> >     End If

> > End Sub


> > > All

> > > this must be one of the easiest questions for you guys....

> > > I know the character number for enter is 13, but i how do i
incorporate
> this
> > > into an if...

> > > If ("Enter key pressed") then

> > >     msgbox("mark is {*filter*}at VB")

> > > end if

> > > i have tried quite a few things but just cannot seem to get it to
work!!

> > > --
> > > --
> > > Mark Fowkes

Sent via Deja.com http://www.*-*-*.com/
Before you buy.


Sun, 14 Apr 2002 03:00:00 GMT  
 I Feel Embarrassed To Ask This Question
Check the KeyPreview property of your parent form. If set to true then
events go thru the form's keypress etc events...

Lavesh


Quote:
> > Why dont any of the above work?????

> It should work.  Maybe something else is catching the <cr> before your
> function.  Do you have any buttons with the default attribute set to true?

> > i we all sure that 13 is enter?

> Yes.

> > mad.....

> > anyone else?

> You might want to try the keydown event:

> Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)

>     If (KeyCode = vbEnter) Then
>         MsgBox "Keep experimenting with events and you will soon be a
guru"
>     End If

> End Sub

> To make it work anywhere on the form put it in the form's keydown event
and
> set the keypreview property of the form to true.



Sun, 14 Apr 2002 03:00:00 GMT  
 I Feel Embarrassed To Ask This Question
If you have a command button on the form that has the [Default] property set to
true then these events are not generated - Keypress, Keyup, or Keydown where the
key pressed is [ENTER].  To make it work set the default property of the command
button to false.
Quote:

> Why dont any of the above work?????

> i we all sure that 13 is enter?

> mad.....

> anyone else?
> --
> --
> Mark Fowkes

> - What I am Now Reading!
> - When The Wind Blows, James Patterson
> -
> http://www.*-*-*.com/
> 26-7854878-1469213

> _________________________________________________

>                      Final Year Bsc Computing
>                 De-Montfort University Leicester


>                            ICQ No: 30486452

>                               Web Page:
>       http://www.*-*-*.com/
> _________________________________________________



> > Mark,

> > Private Sub Text1_KeyPress(KeyAscii As Integer)

> >     If (KeyAscii = 13) Then
> >         MsgBox "Keep asking questions and you will soon be a guru"
> >     End If

> > End Sub


> > > All

> > > this must be one of the easiest questions for you guys....

> > > I know the character number for enter is 13, but i how do i incorporate
> this
> > > into an if...

> > > If ("Enter key pressed") then

> > >     msgbox("mark is {*filter*}at VB")

> > > end if

> > > i have tried quite a few things but just cannot seem to get it to work!!

> > > --
> > > --
> > > Mark Fowkes



Mon, 20 May 2002 03:00:00 GMT  
 I Feel Embarrassed To Ask This Question
The form has a KeyPreview property, make sure that is set to TRUE.



Quote:
> If you have a command button on the form that has the [Default]
property set to
> true then these events are not generated - Keypress, Keyup, or
Keydown where the
> key pressed is [ENTER].  To make it work set the default property of
the command
> button to false.


> > Why dont any of the above work?????

> > i we all sure that 13 is enter?

> > mad.....

> > anyone else?
> > --
> > --
> > Mark Fowkes

> > - What I am Now Reading!
> > - When The Wind Blows, James Patterson
> > -

http://www.*-*-*.com/
-1/0

- Show quoted text -

Quote:
> > 26-7854878-1469213

> > _________________________________________________

> >                      Final Year Bsc Computing
> >                 De-Montfort University Leicester


> >                            ICQ No: 30486452

> >                               Web Page:
> >       http://www.*-*-*.com/
> > _________________________________________________





- Show quoted text -

Quote:

> > > Mark,

> > > Private Sub Text1_KeyPress(KeyAscii As Integer)

> > >     If (KeyAscii = 13) Then
> > >         MsgBox "Keep asking questions and you will soon be a guru"
> > >     End If

> > > End Sub


> > > > All

> > > > this must be one of the easiest questions for you guys....

> > > > I know the character number for enter is 13, but i how do i
incorporate
> > this
> > > > into an if...

> > > > If ("Enter key pressed") then

> > > >     msgbox("mark is {*filter*}at VB")

> > > > end if

> > > > i have tried quite a few things but just cannot seem to get it
to work!!

> > > > --
> > > > --
> > > > Mark Fowkes

Sent via Deja.com http://www.*-*-*.com/
Before you buy.


Wed, 22 May 2002 03:00:00 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Embarrassed even to ask-Why is equal unequal in Access VB

2. I'm embarrassed to ask this but...

3. I feel silly asking this (windows forms)

4. This is such an embarrassing question

5. Feeling really stupid (vb6 question)

6. Feeling like an idiot... AGAIN Checkbox question

7. FAQ = Frequently Asked Questions - vba - Please read before posting questions - unofficial - March posting

8. FAQ: Frequently Asked Questions - vba - please read before posting questions - unofficial February posting

9. FAQ - Frequently Asked Questions - vba - Please read before posting questions - unofficial - Jan 2003 posting

10. FAQ - frequently asked VBA questions - please read before posting questions - September posting - unofficial

11. FAQ - Frequently Asked Questions (vba) - please read before posting questions - August posting - unofficial

12. FAQ - Frequently Asked Questions - unoffical July posting - please read before posting questions - vba

 

 
Powered by phpBB® Forum Software