How do I get my text boxes to automatically highlight the default text so users can start typing without having to delete or highlight it themselves?

Member Avatar for AlanC

Hi
To select text in a textbox control, you just need to specify the start and length of the selection, in characters. Paste this code into the form.load event handler, or wherever you want it..

'set selection start to char 0
Text1.SelStart = 0
'set selection length to the length of whatever's in the text box
Text1.SelLength = Len(Text1.Text)

Hope this helps
Alan

Thanks alot. That works nicely. :D

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.