Solved

Overtyping in a text box

Posted on 2000-03-15
6
203 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
  • 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 20 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…
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…

760 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

21 Experts available now in Live!

Get 1:1 Help Now