Thread: Integer Problem
View Single Post
  #2 (permalink)  
Old October 25th, 2006, 06:28 AM
mmcdonal mmcdonal is offline
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hi,

   Here is the flow control. This should get you there.

'------Code Starts-----------
'Your initial value
s = "0001"

'Convert to Integer
i = CInt(s)

'Add 1 to integer
i = i + 1

'Set the length of the string
l = 4

'Set the initial value of the string variable
str = CStr(i)

'Loop through the string variable adding leading 0 until length = l
Do Until Len(str) = l
    str = "0" & str
Loop

'Print Screen
WScript.Echo str

'-------Code Ends-------------

HTH

mmcdonal
Reply With Quote