Solved

Highlight text in textbox

Posted on 1998-08-01
3
242 Views
Last Modified: 2010-05-03
When updating, how do you get the text already in a textbox to highlight when that box gets the focus?
0
Comment
Question by:mwigg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
percosolator earned 100 total points
ID: 1467458
------------

Private Sub Text1_GotFocus()

    Text1.SelStart = 0
    Text1.SelLength = Len(Text1.Text)
   
End Sub

------------
or
------------

Private Sub Text1_GotFocus()
   
    SendKeys "{HOME}"
    SendKeys "+{END}"
   
End Sub

------------
What I have done is put the first method into an OCX and just use the OCX instead of the text box.  That way you don't have to write that code hundreds and hundreds of times.


0
 
LVL 2

Expert Comment

by:percosolator
ID: 1467459
P.S.  If you would like the source code to compile the OCX, you are welcome to it.  Been using it for four months and it hasn't had any problems.... :)

0
 

Author Comment

by:mwigg
ID: 1467460
I sometimes find microsoft help cryptic, even when they provide examples.

Thanks for your help

Mike
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question