How To Append Trailing Zero

  • Thread starter Thread starter keali
  • Start date Start date
K

keali

for example:
A1 = 123
A1=123000 <- final result

A1 =1234
A1=123400<- final result

A1=1
A1=100000<-final result

How do i append trailing zero? is there a function that i
can use for this?
i cannot use format(A1,"000000") because it append zero in
front.
 
Keali,
Is A1 a String or a Integer?

Have you tried the String.PadRight function?

Dim A1 As String = "123"
A1 = A1.PadRight(6, "0"c)

If A1 is an Integer, I'm not sure of a "better" (another) method then
converting to a string, using PadRight, and converting back.

Hope this helps
Jay
 
You could do

A1 = CStr(123).PadRight(5,"0")
This will pad your var to a _total width_ of 5, .... not "with 5 zeroes".

Or if you know you need it padded with 5 zeroes always, you could do
A1 = 123 * (10^5)
 
Hi Jay B. Harlow [MVP - Outlook], Eidolon

thank for the reply, it's really help me a lot
thank a zillions :)
 
Back
Top