Here's a nice little function that works something like the .NET string.Format function. I did this quickly so adding err handling is up to you. I did this in VB6 and added a reference to Microsoft VBScript Regular Expressions 5.5
Public Function StringFormat(ByVal SourceString As String, ParamArray Arguments() As Variant) As String
Dim objRegEx As RegExp ' regular expression object
Dim objMatch As Match ' regular expression match object
Dim strReturn As String ' the string that will be returned
Set objRegEx = New RegExp
objRegEx.Global = True
objRegEx.Pattern = "(\{)(\d)(\})"
strReturn = SourceString
For Each objMatch In objRegEx.Execute(SourceString)
strReturn = Replace(strReturn, objMatch.Value, Arguments(CInt(objMatch.SubMatches(1))))
Next objMatch
StringFormat = strReturn
End Function
Example:
StringFormat("Hello {0}. I'd like you to meet {1}. They both work for {2}. {0} has worked for {2} for 15 years.", "Bruce", "Chris", "Kyle")
Returns:
Hello Bruce. I'd like you to meet Chris. They both work for Kyle. Bruce has worked for Kyle for 15 years.