T
Terry
Hello,
I made this simple function that calculates a next-up
number that has leading zeros (from a string) taking
advantage of a variant data type.
This works fine until the leading characters are not all
zeros. I would like to use a letter at the beginning of
the string in some cases.
I'm looking for suggestions on how to efficiently split
the string, do the calculation, and then put it back
together again while maintaining the leading Chr.
**********************************************
'example of max: "0000123" or "R000123"
Function nextupNumber(max As String) As String
Dim j As Variant, i As String
Dim clz As Integer, lz As String
i = max
j = max + 1
clz = Len(i) - Len(j)
Select Case clz
Case 1
lz = "0"
Case 2
lz = "00"
Case 3
lz = "000"
Case 4
lz = "0000"
Case 5
lz = "00000"
Case 6
lz = "000000"
Case 7
lz = "0000000"
Case 8
lz = "00000000"
Case Else
lz = ""
End Select
nextupNumber = lz & j
End Function
**********************************************
Any suggestions are greatly appreciated!
Terry
I made this simple function that calculates a next-up
number that has leading zeros (from a string) taking
advantage of a variant data type.
This works fine until the leading characters are not all
zeros. I would like to use a letter at the beginning of
the string in some cases.
I'm looking for suggestions on how to efficiently split
the string, do the calculation, and then put it back
together again while maintaining the leading Chr.
**********************************************
'example of max: "0000123" or "R000123"
Function nextupNumber(max As String) As String
Dim j As Variant, i As String
Dim clz As Integer, lz As String
i = max
j = max + 1
clz = Len(i) - Len(j)
Select Case clz
Case 1
lz = "0"
Case 2
lz = "00"
Case 3
lz = "000"
Case 4
lz = "0000"
Case 5
lz = "00000"
Case 6
lz = "000000"
Case 7
lz = "0000000"
Case 8
lz = "00000000"
Case Else
lz = ""
End Select
nextupNumber = lz & j
End Function
**********************************************
Any suggestions are greatly appreciated!
Terry