Solved

Entering data into text box

Posted on 2002-06-22
7
197 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 70

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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 70

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 70

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
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…

832 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