Fill with zero

N

Newbie

Hi

I have a userform and the value produced from a textbox must be be 10
characters long, i.e. if a 3 digit figure is input, is there a way to precede
this figure with seven zeros?

Grateful for all ideas.
 
R

Rog

Long time since i used this function, but try ;

string$(10-len(yourTextbox.text),"0")

Rgds

Rog
 
J

Jeff Standen

Format(inputvalue,"0000000000")

This will only work if it is an integer. If it is text, something like

length = len(inputvalue)
if length<10 then
for i = 1 to 10-length
inputvalue="0" & inputvalue
next
end if

Although, there's probably a more elegant way.

Jeff
 
Top