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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to add leading zeros to a variable

Status
Not open for further replies.

garethn

Programmer
Jul 3, 2001
12
GB
I have a variable (ProductID which currently looks like this

5426

I need to add leading zeros to this field to make it up to 18 chars long...so it looks like this

000000000000005426

currently have the length of the string

'read/loop array

For r = 1 To rcount
ProductID = arrProductBudget(r, 1)
ProductDesc = arrProductBudget(r, 2)
PriceInZpic = arrProductBudget(r, 3)

Length = 18

test = (Length - Len(ProductID))

but need to know how to add the correct leading zeros
 
Try using:
String(number, character)
number = 18 - the length of the string
character = "0"

Hope it helps
Rob
 
Hi,

ProductID = Format(arrProductBudget(r, 1),"0000000000000000000")

Is another possibility.

Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top