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
Solved

Highlight text in textbox

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

790 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