Click to See Complete Forum and Search --> : [*resolved] formatting a string...
MrPolite
Feb 1st, 2003, 04:09 PM
I have a string and I want to make sure that the string is 6 characters long. If it's smaller, my program should put "0" for the missing characters. For example, "AA" would be "AA0000". This would be easy if this was a number, because the Format function would do it. But it doesnt work with strings. Is there a function similar to the Format function for this purpose?
hellswraith
Feb 1st, 2003, 05:50 PM
Can't you do something similar to this:
if mystring.Length < 6 then
for mystring.Length to 6
mystring += "0"
next
end if
MrPolite
Feb 1st, 2003, 05:55 PM
Originally posted by hellswraith
Can't you do something similar to this:
if mystring.Length < 6 then
for mystring.Length to 6
mystring += "0"
next
end if yeah I did something like that, but I was just wondering if there is a function for these kinds stuff. sounds like there isnt...
thanks :)
FireRabbit
Feb 1st, 2003, 11:20 PM
How about
MsgBox("AA".PadRight(6, "0"))
?
MrPolite
Feb 1st, 2003, 11:31 PM
Originally posted by FireRabbit
How about
MsgBox("AA".PadRight(6, "0"))
? exactly what I was looking for:) thanks!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.