Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 4th, 2004, 04:37 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cochin, Kerala, India.
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default return key based navigation VB 6.0

I have a fairly big VB 6.0 application with a large number of forms. Each of them contains a number of controls also. The tab indices of each control in each form is correctly set so that users can move from control to control using tab key.

However, client wants return (enter) key based navigation. I.e when they press enter key while on a textbox with tab index 16, the focus should move to control with tab index 17 if it is enabled. If control with tab index 17 is not enabled, it should focus to control with tab index 18 and so on.

I can write a piece of code in the key-press event of all controls. But I would like to know whether there are any alternative smarter methods for achieving this ? (Writing such a piece of code in each control key press event will take long time even if I create a public subroutine in a module and use it).

Thanks

Madhu
Reply With Quote
  #2 (permalink)  
Old October 4th, 2004, 05:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

I remember "stephanel" posting a very neat solution to a similar problem a while back. See http://p2p.wrox.com/topic.asp?TOPIC_ID=4052

The original problem was how to get each text box to automatically select all text when focused without writing code in each GotFocus. The solution could easily be applied to your case too using the keypress event instead.

hth
Phil
Reply With Quote
  #3 (permalink)  
Old October 4th, 2004, 01:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Alameda, ca, USA.
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Setting the KeyPreview of the form to True you can send a TAB when the Return key is pressed:

Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        SendKeys "{TAB}"
        KeyAscii = 0 '' "eat" this event
    End If
End Sub

I understand that that is a customer request, nevertheless I discorage changing the standard Windows keystrokes process, especially the Return key that has a completely different meaning (that is, take the "default" action). You get used to Return to switch focus, and then at the first visited web page the Return will click on the "send all the information in this page" default button at the bottom of the page, even though nothing has been entered yet, or worse, sommething wrong was entered...

Marco
Reply With Quote
  #4 (permalink)  
Old October 6th, 2004, 04:32 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cochin, Kerala, India.
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Thanks for the responses.

I tried the stephanel method. But, I have a problem. There it was dealing with only textboxes. I am using all types of controls. So, I have to use different classes for each type of control. It is working for text controls.

Thanks again.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
capture return key in keydown event kawak_zx7 .NET Framework 1.x 1 April 23rd, 2007 11:21 AM
Return Primary Key of Last Append Query mselkregg Access 1 November 16th, 2006 11:36 AM
Multiple Forms and the Return Key Focus rit01 ASP.NET 2.0 Basics 4 June 20th, 2006 01:44 PM
how to pass return value from Jscript to VB hertendreef ASP.NET 2.0 Professional 0 May 30th, 2006 11:01 AM
Key based array in VBScript? rgalehouse Classic ASP Basics 3 March 1st, 2004 06:05 PM



All times are GMT -4. The time now is 04:33 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.