Solved

Highlight text in textbox

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel - Save a copy of work book 13 91
message box in access 4 52
VB 6 error 5 in windows 10 but not in XP 7 67
Powerpoint 2013: Change cell reference in excel link 3 119
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

685 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