Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default KeyAscii won't capture the <Tab key

Hi Bill,

From help -
"The KeyPress event occurs when the user presses a key that produces a
typeable character (an ANSI key) on a running form while the form or a
control on it has the focus."

Keypress will not return Tab, Enter or Arrow keys

Use either the Keydown or KeyUp events and return Keycode.

What can I do to make <Tab execute the right procedures rather than jump

to
the first enabled control?


I'm not sure what you mean by "execute the right procedures" but maybe
merely changing the tab orders (Tabindex) will suffice, try the tab wizard
in View Tab order.

Regards,
Peter T


"Bill Case" wrote in message
...
Hi;

In my procedure below, I need to capture the <LineFeed <Space <Tab or
<Click. I have managed to redirect everything but the <Tab. I have

tried
various values including 9, "9", Chr(9) and vbTab. Nothing works.

What can I do to make <Tab execute the right procedures rather than jump

to
the first enabled control? Something in Excel is overriding VBA.

Private Sub EnterButt0_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)


If KeyAscii = 9 Then
InsertBlankRow
CntrlsOpen
DayJoinedTxt0.SetFocus
End If

End Sub

Regards Bill



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default KeyAscii won't capture the <Tab key

Hi Peter;

Thanks; KeyDown solved it. What is the difference between KeyDown and Keyup
? I know how keyboards work; i.e. scan codes and all that; but
programmaticlly why might I choose KeyDown over KeyUp or viceversa in VBA?

By "execute the right procedures" I meant the two procedures, "InsertBlankRow
CntrlsOpen", that I had included with my original sample.

Regards Bill

"Peter T" wrote:

Hi Bill,

From help -
"The KeyPress event occurs when the user presses a key that produces a
typeable character (an ANSI key) on a running form while the form or a
control on it has the focus."

Keypress will not return Tab, Enter or Arrow keys

Use either the Keydown or KeyUp events and return Keycode.

What can I do to make <Tab execute the right procedures rather than jump

to
the first enabled control?


I'm not sure what you mean by "execute the right procedures" but maybe
merely changing the tab orders (Tabindex) will suffice, try the tab wizard
in View Tab order.

Regards,
Peter T


"Bill Case" wrote in message
...
Hi;

In my procedure below, I need to capture the <LineFeed <Space <Tab or
<Click. I have managed to redirect everything but the <Tab. I have

tried
various values including 9, "9", Chr(9) and vbTab. Nothing works.

What can I do to make <Tab execute the right procedures rather than jump

to
the first enabled control? Something in Excel is overriding VBA.

Private Sub EnterButt0_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)


If KeyAscii = 9 Then
InsertBlankRow
CntrlsOpen
DayJoinedTxt0.SetFocus
End If

End Sub

Regards Bill




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default KeyAscii won't capture the <Tab key

What is the difference between KeyDown and Keyup

The KeyDown occurs when you hit a key with the control in focus and Keyup
when the key is released. If the key is a tab or arrow key (or alt shortcut)
you might only get keydown of the original control and keyup of the newly
activated control. I'm thinking this answer seems too obvious or did you
mean something else!

Regards,
Peter T

"Bill Case" wrote in message
...
Hi Peter;

Thanks; KeyDown solved it. What is the difference between KeyDown and

Keyup
? I know how keyboards work; i.e. scan codes and all that; but
programmaticlly why might I choose KeyDown over KeyUp or viceversa in VBA?

By "execute the right procedures" I meant the two procedures,

"InsertBlankRow
CntrlsOpen", that I had included with my original sample.

Regards Bill

"Peter T" wrote:

Hi Bill,

From help -
"The KeyPress event occurs when the user presses a key that produces a
typeable character (an ANSI key) on a running form while the form or a
control on it has the focus."

Keypress will not return Tab, Enter or Arrow keys

Use either the Keydown or KeyUp events and return Keycode.

What can I do to make <Tab execute the right procedures rather than

jump
to
the first enabled control?


I'm not sure what you mean by "execute the right procedures" but maybe
merely changing the tab orders (Tabindex) will suffice, try the tab

wizard
in View Tab order.

Regards,
Peter T


"Bill Case" wrote in message
...
Hi;

In my procedure below, I need to capture the <LineFeed <Space <Tab

or
<Click. I have managed to redirect everything but the <Tab. I have

tried
various values including 9, "9", Chr(9) and vbTab. Nothing works.

What can I do to make <Tab execute the right procedures rather than

jump
to
the first enabled control? Something in Excel is overriding VBA.

Private Sub EnterButt0_KeyPress(ByVal KeyAscii As

MSForms.ReturnInteger)


If KeyAscii = 9 Then
InsertBlankRow
CntrlsOpen
DayJoinedTxt0.SetFocus
End If

End Sub

Regards Bill






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default KeyAscii won't capture the <Tab key

Hi Peter;

Your right, that was obvious. I was trying to avoid that answer when I
wrote "but
programmaticlly why might I choose KeyDown over KeyUp or viceversa in VBA? ".

What I meant was: when I come to write code for a key action the VBE gives
me a choice of "Private Sub ButOrWhatever_KeyDown(ByVal KeyCode As
MSForms.ReturnInteger, ByVal Shift As Integer)" and "Private Sub
ButOrWhatever_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As
Integer)". For most uses it seems that it will do the same thing as far as a
User is concerned. When I am writing the code to be executed for a key
action, is there any inherent advantage of choosing keydown over keyup.

Nothing I have read indicates any programming advantage of 'up' over 'down'.
But then, nothing I read or googled for told me that 'KeyPress' couldn't
trap <Tab.

So I guess I was asking if there was some poorly docummented programming
difference other than the obvious Keyboard scanning or looping or mechanical
difference.?

Regards Bill


"Peter T" wrote:

What is the difference between KeyDown and Keyup


The KeyDown occurs when you hit a key with the control in focus and Keyup
when the key is released. If the key is a tab or arrow key (or alt shortcut)
you might only get keydown of the original control and keyup of the newly
activated control. I'm thinking this answer seems too obvious or did you
mean something else!

Regards,
Peter T

"Bill Case" wrote in message
...
Hi Peter;

Thanks; KeyDown solved it. What is the difference between KeyDown and

Keyup
? I know how keyboards work; i.e. scan codes and all that; but
programmaticlly why might I choose KeyDown over KeyUp or viceversa in VBA?

By "execute the right procedures" I meant the two procedures,

"InsertBlankRow
CntrlsOpen", that I had included with my original sample.

Regards Bill

"Peter T" wrote:

Hi Bill,

From help -
"The KeyPress event occurs when the user presses a key that produces a
typeable character (an ANSI key) on a running form while the form or a
control on it has the focus."

Keypress will not return Tab, Enter or Arrow keys

Use either the Keydown or KeyUp events and return Keycode.

What can I do to make <Tab execute the right procedures rather than

jump
to
the first enabled control?

I'm not sure what you mean by "execute the right procedures" but maybe
merely changing the tab orders (Tabindex) will suffice, try the tab

wizard
in View Tab order.

Regards,
Peter T


"Bill Case" wrote in message
...
Hi;

In my procedure below, I need to capture the <LineFeed <Space <Tab

or
<Click. I have managed to redirect everything but the <Tab. I have
tried
various values including 9, "9", Chr(9) and vbTab. Nothing works.

What can I do to make <Tab execute the right procedures rather than

jump
to
the first enabled control? Something in Excel is overriding VBA.

Private Sub EnterButt0_KeyPress(ByVal KeyAscii As

MSForms.ReturnInteger)


If KeyAscii = 9 Then
InsertBlankRow
CntrlsOpen
DayJoinedTxt0.SetFocus
End If

End Sub

Regards Bill






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default KeyAscii won't capture the <Tab key

I wouldn't say there's any particular advantage over keydown vs keyup, it's
case of which event best suits needs. Eg do you want to react the moment
user presses a key or when it's released, In some scenarios you might want
to trap both events. The keycode will return same in both events.

I've never found a use for the Keypress event in VBA, though I suppose it
might be useful to return the 'character' code, ie keyascii, rather than
keycode which is not necessarily the same, eg "a" or "A", or directly return
characters that have dual keys such as numbers.

Regards,
Peter T

"Bill Case" wrote in message
...
Hi Peter;

Your right, that was obvious. I was trying to avoid that answer when I
wrote "but
programmaticlly why might I choose KeyDown over KeyUp or viceversa in VBA?

".

What I meant was: when I come to write code for a key action the VBE gives
me a choice of "Private Sub ButOrWhatever_KeyDown(ByVal KeyCode As
MSForms.ReturnInteger, ByVal Shift As Integer)" and "Private Sub
ButOrWhatever_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As
Integer)". For most uses it seems that it will do the same thing as far

as a
User is concerned. When I am writing the code to be executed for a key
action, is there any inherent advantage of choosing keydown over keyup.

Nothing I have read indicates any programming advantage of 'up' over

'down'.
But then, nothing I read or googled for told me that 'KeyPress' couldn't
trap <Tab.

So I guess I was asking if there was some poorly docummented programming
difference other than the obvious Keyboard scanning or looping or

mechanical
difference.?

Regards Bill


"Peter T" wrote:

What is the difference between KeyDown and Keyup


The KeyDown occurs when you hit a key with the control in focus and

Keyup
when the key is released. If the key is a tab or arrow key (or alt

shortcut)
you might only get keydown of the original control and keyup of the

newly
activated control. I'm thinking this answer seems too obvious or did you
mean something else!

Regards,
Peter T

"Bill Case" wrote in message
...
Hi Peter;

Thanks; KeyDown solved it. What is the difference between KeyDown and

Keyup
? I know how keyboards work; i.e. scan codes and all that; but
programmaticlly why might I choose KeyDown over KeyUp or viceversa in

VBA?

By "execute the right procedures" I meant the two procedures,

"InsertBlankRow
CntrlsOpen", that I had included with my original sample.

Regards Bill

"Peter T" wrote:

Hi Bill,

From help -
"The KeyPress event occurs when the user presses a key that produces

a
typeable character (an ANSI key) on a running form while the form or

a
control on it has the focus."

Keypress will not return Tab, Enter or Arrow keys

Use either the Keydown or KeyUp events and return Keycode.

What can I do to make <Tab execute the right procedures rather

than
jump
to
the first enabled control?

I'm not sure what you mean by "execute the right procedures" but

maybe
merely changing the tab orders (Tabindex) will suffice, try the tab

wizard
in View Tab order.

Regards,
Peter T


"Bill Case" wrote in message
...
Hi;

In my procedure below, I need to capture the <LineFeed <Space

<Tab
or
<Click. I have managed to redirect everything but the <Tab. I

have
tried
various values including 9, "9", Chr(9) and vbTab. Nothing works.

What can I do to make <Tab execute the right procedures rather

than
jump
to
the first enabled control? Something in Excel is overriding VBA.

Private Sub EnterButt0_KeyPress(ByVal KeyAscii As

MSForms.ReturnInteger)


If KeyAscii = 9 Then
InsertBlankRow
CntrlsOpen
DayJoinedTxt0.SetFocus
End If

End Sub

Regards Bill








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel screen capture to capture cells and row and column headings jayray Excel Discussion (Misc queries) 5 November 2nd 07 11:01 PM
KeyAscii won't capture the <Tab key Bob Phillips Excel Programming 0 October 1st 06 09:39 AM
Capture a worksheet in VBA Madiya Excel Programming 6 August 11th 06 03:40 PM
Capture the Workbook Name Minitman Excel Worksheet Functions 12 December 7th 05 04:50 PM
Up Capture Alex Excel Programming 0 July 26th 04 08:09 PM


All times are GMT +1. The time now is 09:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"