473,396 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using Enter key to Tab between fields

Having taken the plunge to
update from VB4 to Visual Basic.NET, I'm having trouble with some syntax.
Specifically, I used to use the Keypress event to send a Tab when the Enter
key was pressed:
Private Sub txthead1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then SendKeys "{TAB}"
End Sub

I would like to do this in Visual Basic.NET but can't for the life of me
work out how to do this! Any advice would be very gratefully received.

I'm also having a problem getting a text box to hightlight its contents when
it gets the focus - in VB4 is used to use:
Private Sub txthead1_GotFocus()
txthead1.SelStart = 0
txthead1.SelLength = Trim(Len(txthead1.Text))
End Sub

However it seems that this too has changed (and the VB6 converter tool isn't
a lot of help to me, as I can't yet understand what half of its suggestions
mean!).

Many thanks in advance for any advice.

Nov 21 '05 #1
2 1660
Hi

Try these.

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
System.Windows.Forms.SendKeys.Send("{TAB}")

End Sub
Private Sub TextBox1_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox1.GotFocus

TextBox1.SelectAll()

End Sub

Mike

"LCAdeveloper" <LC**********@discussions.microsoft.com> wrote in message
news:AC**********************************@microsof t.com...
Having taken the plunge to
update from VB4 to Visual Basic.NET, I'm having trouble with some syntax.
Specifically, I used to use the Keypress event to send a Tab when the Enter key was pressed:
Private Sub txthead1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then SendKeys "{TAB}"
End Sub

I would like to do this in Visual Basic.NET but can't for the life of me
work out how to do this! Any advice would be very gratefully received.

I'm also having a problem getting a text box to hightlight its contents when it gets the focus - in VB4 is used to use:
Private Sub txthead1_GotFocus()
txthead1.SelStart = 0
txthead1.SelLength = Trim(Len(txthead1.Text))
End Sub

However it seems that this too has changed (and the VB6 converter tool isn't a lot of help to me, as I can't yet understand what half of its suggestions mean!).

Many thanks in advance for any advice.


Nov 21 '05 #2
Many thanks Michael: I shall try your code suggestions in the morning (when
my eyes have uncrossed from today's headbanging!) ;-)

"Michael Turner" wrote:
Hi

Try these.

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
System.Windows.Forms.SendKeys.Send("{TAB}")

End Sub
Private Sub TextBox1_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox1.GotFocus

TextBox1.SelectAll()

End Sub

Mike

"LCAdeveloper" <LC**********@discussions.microsoft.com> wrote in message
news:AC**********************************@microsof t.com...
Having taken the plunge to
update from VB4 to Visual Basic.NET, I'm having trouble with some syntax.
Specifically, I used to use the Keypress event to send a Tab when the

Enter
key was pressed:
Private Sub txthead1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then SendKeys "{TAB}"
End Sub

I would like to do this in Visual Basic.NET but can't for the life of me
work out how to do this! Any advice would be very gratefully received.

I'm also having a problem getting a text box to hightlight its contents

when
it gets the focus - in VB4 is used to use:
Private Sub txthead1_GotFocus()
txthead1.SelStart = 0
txthead1.SelLength = Trim(Len(txthead1.Text))
End Sub

However it seems that this too has changed (and the VB6 converter tool

isn't
a lot of help to me, as I can't yet understand what half of its

suggestions
mean!).

Many thanks in advance for any advice.


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Peloux | last post by:
Hi, I have written some htc in order to validate data in a form. most of htc are attached on 'onblur' event. Now, we would like to use the Enter Key to sublit form, so we use the following...
1
by: Randy | last post by:
I have trying to figure out the above topic. Can someone help me with this? I need for staff to be able to go to a dialog box or a form and then be able to enter data in mutliple fields and...
1
by: Laszlo Henning | last post by:
I would like to make it possible to jump from a field to another field (the next one in the tab index) using enter also and not only tab. How can this be done either without onkeydown or with it. ...
2
by: anony | last post by:
Maybe this feature is already out there. I guess you could write triggers to do some of this. Often when designing a database I add a start_date and end_date column to the table. The start_date...
1
by: Andrew | last post by:
Hi! I'm new to c# and I stumbled across this dillema during a project: can anyone tell me how I can emulate the action af a Tab when enter is pressed? I saw something in visual basic that looked...
1
by: BisterBooster | last post by:
Hi, Can someone help me for next problem How to for using ENTER key to move to the right cell instead of the TAB key Many thanks in advance Marc.
18
by: Andrew Gentile | last post by:
Hello, I would like to find a way of using scanf() and the Enter key to have user-controlled program flow. Currently, I have a couple of lines in my program which serves as a pause in the...
5
by: mfaisalwarraich | last post by:
Hi, I have a table called mainTable. two fields of this table are SNO which is text and Relation which is also text. there are more than 10 fields in this table. i made a small form called...
1
Shashi Sadasivan
by: Shashi Sadasivan | last post by:
Hi, Due to a certain circumstance i have to add a field to my table, which would be a varchar type. this varchar contructs istfel using 4 fields of type bit so if the table def goes as isA(bit),...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.