Solved

highlighting Visual Basic textbox

Posted on 2000-02-23
10
280 Views
Last Modified: 2013-11-25
Is there a way of highlighting a textbox when the textbox receives the focus?  

I have a textbox with a value in it and when I tab into that textbox, I want to highlight it so that I can just type and it will erase the text that was in there and replace it with the new text.  

Thanks
0
Comment
Question by:Taitor
  • 5
  • 4
10 Comments
 
LVL 7

Accepted Solution

by:
kamall earned 50 total points
ID: 2552885
Use:

Private Sub Text1_GotFocus()

    Text1.SelLength = Len(Text1)

End Sub

Regards.
0
 
LVL 7

Expert Comment

by:kamall
ID: 2552891
Better, use this code:

Private Sub Text1_GotFocus()

    Text1.SelStart = 0
    Text1.SelLength = Len(Text1)

End Sub

0
 
LVL 6

Expert Comment

by:Marine
ID: 2552894
this is simple but maybe better approaches found.
this goes into getfocus of textbox event
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
0
 
LVL 6

Expert Comment

by:Marine
ID: 2552897
GRR i hate when that happends.
0
 
LVL 7

Expert Comment

by:kamall
ID: 2552908
Marine,
What is the difference between my code and yours!!!
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 6

Expert Comment

by:Marine
ID: 2552939
absolutely none. the thing is i had a window with a question open earlier but entered results later then you did so i didn't see your posted answer before i submited mine.
0
 

Author Comment

by:Taitor
ID: 2552945
kamall

That seems to work good.

Thanks  
0
 
LVL 7

Expert Comment

by:kamall
ID: 2552955
Taitor,
you are welcome.

Marine,
It always happens to all of us :-)
0
 
LVL 6

Expert Comment

by:Marine
ID: 2552963
i like this board, i learn a lot from it so if i can help in any way its good for me even if someone beats me to it :) I read your profile you got lots of years experience thats really good. Maybe some day i am going to be just as an experienced :-). Catch you later.
0
 
LVL 7

Expert Comment

by:kamall
ID: 2552980
Marine,
I hope you all the success in your future :-)
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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.
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…
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…

747 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

10 Experts available now in Live!

Get 1:1 Help Now