I actually want to ask two things,
first, how do I set Textbox1 to get focus so that the user will not have to click the textbox if he wants to write something, the .focus() method does not work

also, how do I highlight texts inside a textbox programmatically. I think the equivalent code for this in VB 6.0 is Home+End. I hope you got I mean

If you have a text field named txtMytext and it contains "abcdefghijklmnop" then the following code

txtMytext.Focus()
txtMytext.SelectionStart = 3
txtMytext.SelectionLength = 6

will set focus to the control with "defghi" selected.

This will work only if you are trying to highlight everything in the textbox.

TextBox1.Focus()
TextBox1.SelectAll()

To do the focus and highligh all the text inside ot it:

texrBox1.Focus()
texrBox1.SelectionStart = 0
texrBox1.SelectionLength = textBox1.Text.Lenght

Guys, you've been very helpful to me, thanks. I love you!!! this thread has been solved!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.