|
-
Mar 14th, 2003, 05:00 PM
#1
Thread Starter
Member
KeyDown event
I have a text box. If the text box has text entered previously then I want to discourage the use of the BACKSPACE and ARROW keys thereby preventing the previously entered text from being deleted. New text is OK. It seems to work fine with the arrow keys but not for the BACKSPACE key. The following is my code.
Help.
Private Sub txtComment_KeyDown(KeyCode As Integer, Shift As Integer)
dim strLen as String
dim blnInsert as Boolean
strLen = Len(txtComment.text)
Select Case KeyCode
Case 8
If strLen > 0 Then
'SendKeys "(^Z)"
KeyCode =0
End If
Case 37, 38, 39, 40
If strLen > 0 Then
KeyCode = 0
End If
Case Else
If Not blnInsert Then
If txtComment.Text = "" Then
'txtComment.Text = CStr(Now()) & " Modified By "
Else
txtComment.Text = txtComment.Text & vbCrLf & CStr(Now()) & " Modified By "
End If
txtComment.SelStart = Len(txtComment.Text)
blnInsert = True
End If
End Select
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|