String.format

francoisg

Active Member
Licensed User
Longtime User
Hi,
maybe I am just missing the docs somewhere but is there something like the .net (and others) String.Format method (For example something like "abc_{0}_def_{1}_".Format("11", "22") results in "abc_11_def_222") ???

Makes the reading of code SO much easier (and cleaner!!)

Currently I have a sub (see below) that does the trick but there MUST be a cleaner way???

Sub StringFormat (Value As String, Params As List)
For i = 0 To Params.Size-1
Value = Value.Replace("{" & i & "}", Params.Get(i))
Next
Return Value
End Sub


Usage: StringFormat("abc_{0}_def_{1}", Array As Object("11", "22")
 

francoisg

Active Member
Licensed User
Longtime User
Thanx,
think I'll stay with my slower but MUCH more generic (and more readable code) sub for now ... ;-)
 
Top