473,396 Members | 1,760 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.

MaxLength of textbox and Focus change

GBW
I'm new to VB .NET development - I'm trying to create a
text box that as soon 3 characters are entered the focust
will then move to the next text box I've tried using
MaxLength or textbox.selection.length = 3. It will move
the focus when you select the 4th character to enter but
I would like it to automatically move focus when 3
characters are entered. I know this must be simple but
I'm in the weeds right now... Thanks.
Nov 20 '05 #1
3 16046
Instead of checking for 3 check for 2.

I checked with two textboxes textbox1, textbox2. Textbox1 has tabindex 1 and
textbox2 has tabindex 2.

I entered the following code. It works.

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged

If Len(TextBox1.Text) > 2 Then

TextBox2.Focus()

End If

End Sub

"GBW" <br*********@verizon.net> wrote in message
news:00****************************@phx.gbl...
I'm new to VB .NET development - I'm trying to create a
text box that as soon 3 characters are entered the focust
will then move to the next text box I've tried using
MaxLength or textbox.selection.length = 3. It will move
the focus when you select the 4th character to enter but
I would like it to automatically move focus when 3
characters are entered. I know this must be simple but
I'm in the weeds right now... Thanks.

Nov 20 '05 #2
thank you! That definitely does work..I'm trying to
include this though with a keypress event. If someone
presses the "." button, I'd also like it to change focus.
(like ip address entry..) Can you include a keypress
event with a text changed event? Thanks again for
helping a newbie...
-----Original Message-----
Instead of checking for 3 check for 2.

I checked with two textboxes textbox1, textbox2. Textbox1 has tabindex 1 andtextbox2 has tabindex 2.

I entered the following code. It works.

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles TextBox1.TextChanged

If Len(TextBox1.Text) > 2 Then

TextBox2.Focus()

End If

End Sub

"GBW" <br*********@verizon.net> wrote in message
news:00****************************@phx.gbl...
I'm new to VB .NET development - I'm trying to create a
text box that as soon 3 characters are entered the focust will then move to the next text box I've tried using
MaxLength or textbox.selection.length = 3. It will move the focus when you select the 4th character to enter but I would like it to automatically move focus when 3
characters are entered. I know this must be simple but
I'm in the weeds right now... Thanks.

.

Nov 20 '05 #3
Hello,

<br*********@verizon.net> schrieb:
thank you! That definitely does work..I'm trying to
include this though with a keypress event. If someone
presses the "." button, I'd also like it to change focus.
(like ip address entry..) Can you include a keypress
event with a text changed event? Thanks again for


You can use 'InStr' or the text's 'IndexOf' method to check if it contains a
"." character.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #4

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

Similar topics

9
by: Lovely Dola | last post by:
I have set the MaxLength property of a textbox in a form to 5 at design time. When I change the MaxLength back to 0 during run-time under some condition (for example, after clicking a command...
0
by: Jonas L | last post by:
Hi, I need to create a textbox which acts as a normal textbox but with the following extra requirements: 1) In-focus color, when the textbox gets focus the backcolor property of the textbox...
13
by: Paul Slavin | last post by:
I have a textbox bound to a dataview, when I update the text in the textbox no changes take place in the underlying dataset. Why is this?? any answers appreciated, as to due to the underlying...
4
by: Jeff Bangert | last post by:
How to turn it off? For example, this code TextBox1.Text = "hello"; puts "hello" in the TextBox, but it is highlighted. I want to turn off the highlighting. I have looked at every TextBox...
3
by: RSB | last post by:
Hi Everyone, I have this TextBox with the TextMode="MultiLine". so now it does not validate the text in the TextBox for the MaxLength SO i have decided to execute a CustomValidator for this...
9
by: The Confessor | last post by:
I declare the following variable in one of my structures... <VBFixedString(17)> Dim Name As String Fixed to 17 because it's written to a random-access file. Is there any way to tie the...
5
by: =?Utf-8?B?QmVuIFIu?= | last post by:
Hi, In a .NET 2.0 winforms application, I've got a textbox that, when updated, uses the validated event to cascade the change to another textbox (along with another value). This works well if...
8
by: Marco Pais | last post by:
Hi there. How can I change the background color of a textbox when it gets the focus? I can handle the "Enter" event and do this private void txtDummie_Enter(object sender, EventArgs e) { ...
10
by: engteng | last post by:
When textbox properties enable = False the font in the textbox become gray color. How do I change the gray color to black color ? Regards, Tee
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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.