Solved

Highlight text in textbox

Posted on 1998-08-01
3
211 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 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now