Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable increment

Status
Not open for further replies.

MrBaRRon

Programmer
Aug 8, 2003
39
IT
Hi everybody


I have a variable I would like to increment 1 by 1 in vbscript

It looks like '001' untill '999'

My problem is when I add "1" to the value "005" (by example) , it don't return '006' but '6' .

I would like to keep this syntax '006'

So what do you propose please ?! ; )

thx

 
you may have to do a bit of string manipulation in vbscript.

We have a function called fillwithleadingzeros that we use in vb - maybe it will help:

Function FillWithLeadingZeros(lngLocalCustomerNumber As Long, intLocalLength As Integer) As String
Dim strA As String
strA = LTrim(Str(lngLocalCustomerNumber))
Do Until Len(strA) = intLocalLength
strA = "0" & strA
Loop
FillWithLeadingZeros = strA

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top