I don't think it's the code because only the method of calling it is the problem. Here is my code, though.
PadLeft, in Module called PadLeft
PadRightCode:Function PadLeft(text, spaces) If Len(text) <= spaces Then PadLeft = Application.Rept(" ", spaces - Len(text)) & text Else PadLeft = text & " has " & Len(text) & " space(s). You are asking for " & spaces & " space(s)." End If End Function
Like I said, calling padleft("A",5) doesn't work, but calling PadLeft.PadLeft("A",5), does; calling padRight("A",5) doesn't work, as well, while PadRight.PadRight("A",5) does.Code:Function PadRight(text, spaces) If Len(text) <= spaces Then PadRight = text & Application.Rept(" ", spaces - Len(text)) Else PadRight = text & " has " & Len(text) & " space(s). You are asking for " & spaces & " space(s)." End If End Function
Here are print screens depicting what I'm doing.
I apologise for the size, but I don't have time to resize them atm because I have a term paper due in less than six hours.






Reply With Quote
Bookmarks