|
-
Sep 19th, 2000, 11:18 PM
#1
Thread Starter
Frenzied Member
I tried to use Keypress Event to disable the Tab Key. In Keypress Subroutine, I used "KeyAscii = 0" when vbKeyTab occurred. Text box still lost focus. I used same code to ignore Enter key and it worked as expected.
Advice anybody?
Thanx.
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
-
Sep 20th, 2000, 12:14 AM
#2
Try switching the forms "KeyPreview" property to true, and then typing some code in the KeyPress event of the form. Sorry, but I can't help you out with the code if you are after it.
-
Sep 20th, 2000, 12:42 AM
#3
Hyperactive Member
Actually... The "KeyPreview" attribute tells the form to "CHECK" all keystrokes before allowing the relevant control to test for it.
What you want to do is test for the KeyDown even rather than KeyPress.
I think Tab is a value of 14 by memory but I could be wrong.
-
Sep 20th, 2000, 12:46 AM
#4
Lively Member
Sorry Gen-X, but Tab is a value of 9
-
Sep 20th, 2000, 12:56 AM
#5
Hyperactive Member
Thanks KWell...
I knew it was in the sub 32 range somewhere.
-
Sep 20th, 2000, 12:48 PM
#6
Thread Starter
Frenzied Member
Did not work
The following did not work.
Code:
Private Sub TxtMessage_KeyDown(KeyCode As Integer, _
Shift As Integer)
If KeyCode = vbKeyTab Then
KeyCode = 0
Junk = MsgBox("Tab Key") 'Dim for Junk is elsewhere
End If
End Sub
I had similar code in KeyPress event subroutine. Neither recognized the Tab Key. Either the vbKeyTab constant is incorrect (I doubt that) or these subroutines do not provide for trapping & ignoring the Tab Key. Both allow for trapping & ignoring the Return Key.
I tried the above with KeyPreview True & False.
My application can live without trapping the Tab Key. When Text Box is active, no control with a TabStop is visible, so focus is lost. I can Mouse click to return to Text Box, but it makes the application behave in a "Non-Professional" manner.
Any thoughts?
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
-
Sep 21st, 2000, 12:06 AM
#7
Lively Member
Try This
I couldn't figure it out either, but you could put another textbox under the one you are working with(by under I mean same top,left,height and width)and set it active and inactive with the one you are working with, then insert some code like this.
Private Sub txtHidden_GotFocus()
txtYouWantToIgnoreTabKey.SetFocus
End Sub
Not pretty, but it works.(I tried it)
Make sure hidden textbox is next in taborder.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|