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

Equivalent to sprintf/print function?

Status
Not open for further replies.
Jul 16, 2003
3
GB
Can anyone help? I am trying to find a way of easily inserting a value into a string, in a similar manner to the c sprintf function. (Old habits die hard!!)
 
Use the & .....

sTemp = "HELLO WORLD"
'this will place !! in the string,
'after hello.. thus HELLO!! WORLD is now sTemp
sTemp = left(sTemp, 5) & "!!" & right(sTemp, 6)

Hope that helps,

Shane
 
Thanks for this, but what what I wanted was something to work like this

<snip>

strName=&quot;Fred&quot;
strHomeTown=&quot;Smallville&quot;

strOutput = Sprintf(&quot;My Name is %s, and I come from %s&quot;, strName, strHomeTown)

</snip>

which would result in strOutput having the value

My Name is Fred, and I come from Smallville


I have found


which gives me what I want,

or a simpler VBScript version


Again thanks for the rsponse, and perhaps these links will help someone else
 
Try this:
Code:
strName=&quot;Fred&quot;
strHomeTown=&quot;Smallville&quot;
strOutput = &quot;My Name is &quot; & strName & &quot;, and I come from &quot; & strHomeTown

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top