• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

Overtyping in a text box

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
TGB
Asked:
TGB
  • 2
  • 2
  • 2
1 Solution
 
VbmasterCommented:
The easiest solution would be to simple add..

  Text1.SelLength = 1

... to the KeyPress event of the textbox.
0
 
paulstampCommented:
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
 
TGBAuthor Commented:
Cheers. But I can't seem to get the 'Activate' event to come up. What am I doing wrong? (Using VB6.0)
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
VbmasterCommented:
Perhaps this is because there is no Activate event? ;)  The GotFocus() event is probably what paulstamp meant.
0
 
TGBAuthor Commented:
Cheers for the help. ;)
0
 
paulstampCommented:
Sorry... mind going... yes - form_gotfocus()
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now