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

leading zeros...

Status
Not open for further replies.

dodgyone

Technical User
Jan 26, 2001
431
GB
Hi, I've created a field in a table using VBA but
I now need to alter the format.

It's VBLong and I want the format to be '0000'.

So, there are leading zeros depending upon the size of the number... ie:

0001
5463
0567
0057

and so on...

Thanks for the help...
 
You need to input the data into a string field and convert it to a long integer if you need to manipulate it, by math, sorting and so on.
 
Thanks TrojanRabbit... i alrady know how to do that though.

I'm writing an automated procedure for a user group so I really need to do this with vb code to save them the hassle when they do the transfer.
 
Per mikey's suggestion, you can use a string:
numstr = String(4 - Len(CStr(num)),"0") & CStr(num)

There's also Format(num, "0000").
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top