473,387 Members | 1,691 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,387 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 16043
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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
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,...

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.