Adding Letters to Numbers

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
 
G

Guest

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
 
D

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.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top