Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Highlight text in textbox

Posted on 1998-08-01
3
Medium Priority
?
267 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
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
percosolator earned 400 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

926 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