Private Sub Command3_Click()
MsgBox LASTINPUT(Text1)
End Sub
Function LASTINPUT(ByVal TXT As TextBox) As String
If TXT.SelStart < 1 Then LASTINPUT = ""
If TXT.SelStart >= 1 Then LASTINPUT = Mid(TXT.Text, TXT.SelStart, 1)
End Function
Private Sub Form_Load()
strValue = Text1.Text
End Sub
Private Sub Text1_Change()
Dim I As Long, K As Long, strTmp As String
Dim strT1 As String, strT2 As String, strNewStr As String
Dim lValueLen As Long, lTmp As Long
If Len(strValue) = 0 Then
strValue = Text1.Text
Else
strTmp = Text1.Text
K = Len(strTmp)
lValueLen = Len(strValue)
strNewStr = ""
For I = 1 To K
strT1 = Mid(strTmp, I, 1)
If I - lTmp <= lValueLen Then
strT2 = Mid(strValue, I - lTmp, 1)
If strT1 <> strT2 Then
strNewStr = strNewStr & strT1
lTmp = lTmp + 1
End If
Else
strNewStr = strNewStr & strT1
End If
Next
strValue = strTmp
End If
Me.Caption = strNewStr
End Sub