Option Explicit Private txtBoxSelStart As Integer Private txtBoxText As String Private Sub Text1_Change() If Text1.Text = "" Then Exit Sub If IsNumeric(Text1.Text) Then If txtBoxText <> Text1.Text Then txtBoxSelStart = Text1.SelStart Else Text1.SelStart = txtBoxSelStart End If txtBoxText = Text1.Text Else Text1.Text = txtBoxText End If End SubPrivate Sub Text1_GotFocus() txtBoxSelStart = Text1.SelStart txtBoxText = Text1.Text End SubPrivate Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer) If KeyCode >= vbKeyEnd And KeyCode <= vbKeyDown Then txtBoxSelStart = Text1.SelStart End If End SubPrivate Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = vbKeyLButton Then txtBoxSelStart = Text1.SelStart End If End Sub
Private txtBoxSelStart As Integer
Private txtBoxText As String
Private Sub Text1_Change()
If Text1.Text = "" Then Exit Sub
If IsNumeric(Text1.Text) Then
If txtBoxText <> Text1.Text Then
txtBoxSelStart = Text1.SelStart
Else
Text1.SelStart = txtBoxSelStart
End If
txtBoxText = Text1.Text
Else
Text1.Text = txtBoxText
End If
End SubPrivate Sub Text1_GotFocus()
txtBoxSelStart = Text1.SelStart
txtBoxText = Text1.Text
End SubPrivate Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode >= vbKeyEnd And KeyCode <= vbKeyDown Then
txtBoxSelStart = Text1.SelStart
End If
End SubPrivate Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbKeyLButton Then
txtBoxSelStart = Text1.SelStart
End If
End Sub