Solved

Overtyping in a text box

Posted on 2000-03-15
6
220 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

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…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

813 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