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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String spaces

Status
Not open for further replies.

Geates

Programmer
Aug 25, 2009
1,566
US
Is there a VBS function that will allow me to print a string in a static space. Similar to QBasic's SPACE$ or PRINT USING function. My work-around is the below function (may help clarify things).

Code:
function strSpace (str, intLength)
	if (intLength <> -1) then
		if (len(str) > intLength) then
			str = left(str, intLength)
		else
			do until (len(str) = intLength) : str = str & " " : loop
		end if
	end if
	strSpace = str
end function

This begs another question. Is there a way to pass only the necessary arugments to a function. Similar to PHP
function definition:

Code:
function myFunc(arg1, arg2 = false)

-Geates
 
strSpace = Left(str & Space(intLength), intLength)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Excellent. I can make that work.

-Geates
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top