Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Equivalent of "PadLeft" or "PadRight" in VBA

Status
Not open for further replies.

irbk

MIS
Oct 20, 2004
578
US
I'm trying to figure out, in VBA how to do a VB "PadLeft" command. For example, if I have an input of 8750, I want my output to be 0000008750 (which in VB is Variable.PadLeft(10, chrZero)) Having a heck of a time trying to figure out how to do the same thing in VBA.

Thanks in advance.
 
How about
Format(Variable, "0000000000")

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ181-2886 before posting.
 
A starting point:
Function PadLeft(myVar, myLen, myChr)
PadLeft = Right(String(myLen, myChr) & myVar, myLen)
End Function

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top