Hi there,
This, I know is simple but.....
I am doing this simple VBA macro to place numbers (with a prefix) into a Microstation drawing. The number increments by 1 everytime the text is placed.
I have a little function that returns an incremented number. When you pass in a number like IncrementNumber(1) it returns 2.
That's great.
But if you pass in IncrementNumber(001) then it will still return 2. I really want it to be able to return 002
Does anyone have a neat little function to increment a number by 1 while respecting the number of leading zeros (however many there are?)
Private Function IncrementNumber(ByVal sNumber As String) As String
Dim iTemp As Integer
iTemp = CInt(sNumber) + 1
IncrementNumber = CStr(iTemp)
End Function
TIA
Russ
Regards,
Russ
This, I know is simple but.....
I am doing this simple VBA macro to place numbers (with a prefix) into a Microstation drawing. The number increments by 1 everytime the text is placed.
I have a little function that returns an incremented number. When you pass in a number like IncrementNumber(1) it returns 2.
That's great.
But if you pass in IncrementNumber(001) then it will still return 2. I really want it to be able to return 002
Does anyone have a neat little function to increment a number by 1 while respecting the number of leading zeros (however many there are?)
Private Function IncrementNumber(ByVal sNumber As String) As String
Dim iTemp As Integer
iTemp = CInt(sNumber) + 1
IncrementNumber = CStr(iTemp)
End Function
TIA
Russ
Regards,
Russ