Adding Letters to Numbers

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

I want to add a letter after a number...

1
1A
1B
1C

So if I start with 1 when I push a command button the next highest
letter would come up no matter where I start in the sequence.

thanks
DS
 
DS said:
I want to add a letter after a number...

1
1A
1B
1C

So if I start with 1 when I push a command button the next highest
letter would come up no matter where I start in the sequence.

I assume you want to increment this in a textbox on a form. If so, this code
should work:

Dim strOldVal As String
strOldVal = Right(Me.txtValue, 1)
Select Case strOldVal
Case "A" To "y"
Me.txtTop = Left$(Me.txtValue, Len(Me.txtValue) - 1) &
Chr(Asc(strOldVal) + 1)
Case "z"
Me.txtValue= Left$(Me.txtValue, Len(Me.txtValue) - 1) & "a"
End Select

This assumes that your textbox is called txtValue. It also assumes that you
want a value that ends in z to go back to a, but you can change or eliminate
that part if you want.

Barry
 
DS said:
I want to add a letter after a number...

1
1A
1B
1C

So if I start with 1 when I push a command button the next highest
letter would come up no matter where I start in the sequence.

thanks
DS
So this works, but only if the starting number is the ast number in the
sequence.

Me.Text0 = Left(Me.Text0, Len(Me.Text0) - 1) & Chr(Asc(right(Me.Text0,
1)) + 1)

I need it to work so if I start with 1 the next number will be 1D. I'm
getting 2. Any help appreciated.
 
Back
Top