?
Solved

Overtyping in a text box

Posted on 2000-03-15
6
Medium Priority
?
247 Views
Last Modified: 2008-03-04
How do I get VB to allow me to overtype data already contained within a text box, that has already hit its maximum amount of characters? I have a text box with a string of 50 chrs in it, and naturally, when I go to type anything in this box, VB won't let me because the box is full. I want to allow the user to overtype what is already in there - how do I do it? (please help)
0
Comment
Question by:TGB
[X]
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
  • 2
  • 2
  • 2
6 Comments
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2619274
The easiest solution would be to simple add..

  Text1.SelLength = 1

... to the KeyPress event of the textbox.
0
 
LVL 3

Accepted Solution

by:
paulstamp earned 80 total points
ID: 2619308
vbMaster's comment is the answer if you want to overtype a single character... however if you want your typing to replace the entire string use this :

Private Sub Text1_Activate()

    Text1.SelStart = 0
    Text1.SelLength = len(text1.text)

End Sub

When the user clicks on your textbox the entire text will be highlighted and any new text replaces the whole lot.
0
 

Author Comment

by:TGB
ID: 2619327
Cheers. But I can't seem to get the 'Activate' event to come up. What am I doing wrong? (Using VB6.0)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:Vbmaster
ID: 2619359
Perhaps this is because there is no Activate event? ;)  The GotFocus() event is probably what paulstamp meant.
0
 

Author Comment

by:TGB
ID: 2619403
Cheers for the help. ;)
0
 
LVL 3

Expert Comment

by:paulstamp
ID: 2620302
Sorry... mind going... yes - form_gotfocus()
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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 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…
Suggested Courses

649 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