Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a type overmode in VB?

Status
Not open for further replies.

treecody

Programmer
Jul 25, 2001
16
0
0
US
Hi,

I've just written my first VB program. On my edit click event I what to be able to overwrite what is already there. I have a keypress function, which I check for enter, tab and escape. The problem I am having is I start to type and it moves the inforamtion over as if I'm in insert mode, I want to just type over the information already there. Is there a way to toggle the insert key to type over mode?

Any input woud be great.

Thanks..treecody
 
I've tried pressing the insert key but it doesn't work. I have a feeling its because I'm checking if the enter key or the tab key or the escape has been pressed. I am using the form_keypressed event to check for the above keys. If I press any other key then those mentioned I loose my cursor.

Thanks.. treecody
 
I actually commented out that entire sub and it still doesn't work.
All I'm trying to do is use the enter key or the tab key to go from field to field and I want to be able to type over the text already entered. It should be a simply thing, I would think!!!

Here is part of the code

Private Sub form_keypress(keypressed As Integer)
Dim nexttabindex As Integer, i As Integer
If keypressed = vbKeyReturn Or keypressed = vbKeyTab Then
If Screen.ActiveControl.TabIndex = Count - 1 Then
nexttabindex = 0
Else
nexttabindex = Screen.ActiveControl.TabIndex + 1
End If
For i = 0 To Count - 1
If frmtlsdedit.Controls(i).TabIndex = nexttabindex Then
If addclick Then ' used if adding new records
txtsddist_validate (cancel)
If frmtlsdedit.Controls(i).TabIndex = 13 Then
txtothamt1_validate (cancel)
End If
If frmtlsdedit.Controls(i).TabIndex = 15 Then
txtothamt2_validate (cancel)
End If
If frmtlsdedit.Controls(i).TabIndex = 17 Then
txtothamt3_validate (cancel)
End If
If dontmove = False Then
frmtlsdedit.Controls(i).SetFocus
End If
Else
If frmtlsdedit.Controls(i).TabIndex = 11 Then
txtothamt1_validate (cancel)
End If
If frmtlsdedit.Controls(i).TabIndex = 12 Then
txtothamt2_validate (cancel)
End If
If frmtlsdedit.Controls(i).TabIndex = 13 Then
txtothamt3_validate (cancel)
End If
If dontmove = False Then
frmtlsdedit.Controls(i).SetFocus
End If
End If
Exit For
End If
Next i
keypressed = 0
Else
If keypressed = vbKeyEscape Then
addclick = False
val = False ' validation should not occur when esc key is pressed
disfields
resetcmds
End If
End If
End Sub

Let me know what you think.

Thanks..treecody
 
To activate the overtyping you might try the following:

Sub edTextBox_GotFocus

edTextBox.SelStart = 0
edTextBox.SelLength = Len(txtCount.Text)

End Sub

The Tab key will always move to the next control in Tab Order. To "convert" the Return to a Tab, you might try something like this:

Sub edText_KeyPress(KeyAscii As Integer)

If (KeyAscii = Asc(vbCr)) Then
SendKeys vbTab
End If

Exit Sub
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein


 
Thanks, I'll try that and see what happens.

Treecody
 
Hi CajunCenturion,

That worked but that is not exactly how I want it to work. I don't want to delete the entire text. When you are in typeover mode the entire text is not deleted, you just move from character to character. Maybe VB can't do it? Or I'm just making too big of a deal out of it. I'm used to other programming software that provides this feature without having to program it. I have to get used to VB which is not an easy thing to do!!

Thanks again.. Treecody
 
Try this for each textbox

Private Sub Text1_KeyPress(KeyAscii As Integer)
SendKeys ("{Del}")
End Sub

Hope this is what you are looking for. Anything is possible, the problem is I only have one lifetime.
[cheers]
 
Foada,

I tried that but I couldn't get it to work. It was a long day yesterday. I'll try again today. Thanks for the input.

Treecody
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top