Need help... should be simple

fpendino

Registered User.
Local time
Today, 02:51
Joined
Jun 6, 2001
Messages
73
How do you set a value or integer to return a certain amount of characters. Please refer to the example where I am asking to place zeros so that the value is still 4 numbers long.

0005
0025
0035
0100
0001


?expression(txtbox)
 
this is how i do it... atleast this will get you in the right direction

Dim NumX as String

if Len(NumX) = 3 then
NumX = "0" & CStr(NumX)
end if

if Len(NumX) = 2 then
NumX = "00" & CStr(NumX)
end if

if Len(NumX) = 1 then
NumX = "000" & CStr(NumX)
end if


It works for me... :rolleyes:
 
That will work.. Thanks!!
 
If you need it as a string then, simply:


strX = CStr(Format(yourValue, "0000"))
 
MIle,

Why the cstr(format()) and not just format()??

Format returns a string right??

Regards
 
True! :rolleyes:

I probably just had CStr() in my head as I saw it in Treason's solution.
 
Cstr function changes the value to a string...
Cint function changes to an integer etc...

So without the Cstr i would think the formatting wouldn't stick. B/c an integer (probaly) can have the leading zeros.
 

Users who are viewing this thread

Back
Top Bottom