Anyone know how to turn on or off the insertkey in a textbox, so when i write in the textbox i overwrite stuff there. This can be done manually by pressing the Insert key on the keyboard, but I want it to be that way in the textbox.
Printable View
Anyone know how to turn on or off the insertkey in a textbox, so when i write in the textbox i overwrite stuff there. This can be done manually by pressing the Insert key on the keyboard, but I want it to be that way in the textbox.
Code:Private Sub Command1_Click()
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Text1.SetFocus
End Sub
Code:Text1.SetFocus
SendKeys "{INSERT}"
HeSaidJoe's code is exactly correct, but I put the same code (minus the setfocus line) in the GotFocus event. That way whenever the field is entered, the text is selected and can be keyed over immediately.
Code:
Private Sub Text1_GotFocus()
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
End Sub
I'm sorry but I don't agree.
Kedeman's code works better (in this case) because only the characters typed are being overwritten, not all text, it's like virtually pressing the <Insert> key.
That's how i interpreted the qwestion ;)