Fill with zero

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
Long time since i used this function, but try ;

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

Rgds

Rog
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top