lhardee
05-09-2008, 04:46 PM
Hello,
Mike Erickson helped me out a bunch with the following code. I marked the question as solved, but found out that I can not enter zero values. I tried changing "S[1-9]*" to "S[0-9]*" but this did not fix the problem. Could someone show me where I'm going wrong ??
Thanks
Private Sub TextBox1_Change()
Static abort As Boolean
Dim sLStart As Long, sLLength As Long
If abort Then abort = False: Exit Sub
With Me.TextBox1
sLStart = .SelStart
sLLength = .selLength
abort = True
If .Text Like "S[1-9]*" Then
.Text = "S" & Int(Val(Mid(.Text, 2)))
Else
.Text = "S"
End If
.SelStart = Application.Max(sLStart, 1)
.selLength = sLLength
End With
End Sub
lhardee
Mike Erickson helped me out a bunch with the following code. I marked the question as solved, but found out that I can not enter zero values. I tried changing "S[1-9]*" to "S[0-9]*" but this did not fix the problem. Could someone show me where I'm going wrong ??
Thanks
Private Sub TextBox1_Change()
Static abort As Boolean
Dim sLStart As Long, sLLength As Long
If abort Then abort = False: Exit Sub
With Me.TextBox1
sLStart = .SelStart
sLLength = .selLength
abort = True
If .Text Like "S[1-9]*" Then
.Text = "S" & Int(Val(Mid(.Text, 2)))
Else
.Text = "S"
End If
.SelStart = Application.Max(sLStart, 1)
.selLength = sLLength
End With
End Sub
lhardee