Monday, July 25, 2011

How to create a BACKSPACE key?



Option Explicit

Private Sub Command1_Click()
Dim pos As Long
Dim strLeft As String, strRight As String
With Text1
    If Len(.Text) Then
        pos = .SelStart
        If pos Then
            strLeft = Left$(.Text, pos - 1)
            strRight = Mid$(.Text, pos + 1)
            .Text = strLeft & strRight
            .SelStart = pos - 1
        End If
    End If
    .SetFocus
End With

End Sub

No comments:

Post a Comment