Numbers with leading zeroes, using vb6
How can I add leading zeroes to a number? For example:
Dim stracctnumber as String
stracctnumber = 987654321
If stracctnumber
is less than 15 characters, then add leading zeroes开发者_运维问答 to the account number.
The final number should be
stracctnumber = "000000987654321"
Can anyone help me?
stracctnumber = Format(stracctnumber, String(15, "0"))
strAcct = Right("000000000000000" & strAcct, 15)
Note that concatenation is relatively 'expensive'. If this is just for display, rather than modifying the underlying value, consider using the Format()
function.
B8 = Format((Format(B2, "###,###")), "@@@@@@@")
This is to add spaces to left.
WORKS GREAT in VBA Excel.....
精彩评论