Solved

Entering data into text box

Posted on 2002-06-22
7
194 Views
Last Modified: 2010-05-02
I am trying to get visual basic to delete a previous entry shown in a text box when user starts to enter a new entry.  All efforts result new entry adding on to or inserting new text into a prior entry.  MSN says it can be done but fails to tell us how. And many programs do this. It should be unnecessary for user to have to backspace out a previous entry every time a revised entry is entered.

It should be easy???  Why not???
0
Comment
Question by:forrestx
7 Comments
 
LVL 2

Accepted Solution

by:
egsemsem earned 100 total points
ID: 7101020
Add this code in GotFocus event of the text box. As soon as the textbox got focus, all the text will be selected, and so it will be deleted once the user starts typing.

Private Sub Text1_GotFocus()
    Text1.SelStart = 0
    Text1.SelLength = Len(Text1.Text)
End Sub

I hope I have helped,

Osama
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 7101025
Place this code into the GotFocus event

Private Sub Text2_GotFocus()
    With Text2
        .SelStart = 0
        .SelLength = Len(.Text)
    End With
End Sub
0
 
LVL 1

Expert Comment

by:Mahdi Mansour
ID: 7110075
or place this code in gotFocus:

text2.text=""
0
Free Trending Threat Insights Every Day

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.

 
LVL 69

Expert Comment

by:Éric Moreau
ID: 7128885
Any progress?
0
 
LVL 2

Expert Comment

by:egsemsem
ID: 7133856
hi forrestx, where are u?
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 7348059
This question appears to be abandoned. A question regarding it will be left in the CleanUp
area; if you have any comment about the question, please leave it here.

Unless there is objection or further activity, one of the moderators will be asked to accept the comment
of <egsemsem >.

DO NOT ACCEPT THIS COMMENT AS AN ANSWER.
0
 
LVL 5

Expert Comment

by:Netminder
ID: 7373290
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

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

12 Experts available now in Live!

Get 1:1 Help Now