'This should work properly
Private Declare Function GetKeyState Lib "User32" (ByVal nVirtKey As Integer) As Integer
Public Function InsertMode() As Boolean
Dim insert%
insert = GetKeyState(vbKeyInsert)
If insert And 1 Then
InsertMode = True
Else
InsertMode = False
End If
End Function
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim char As String
If InsertMode() = False Then
If Text1.SelLength <= 1 Then
char$ = Mid$((Text1.Text), Text1.SelStart + 1, 1)
If char$ = vbCr Then
Text1.SelLength = 2
Else
Text1.SelLength = 1
End If
End If
End If
End Sub




Reply With Quote