Public Function Replace(strText As String, strReplaceWhat As String, replaceWith As Func(Of String)) As String Dim i As Integer = strText.IndexOf(strReplaceWhat) While i <> -1 strText = strText.Substring(0, i) & replaceWith() & strText.Substring(i + strReplaceWhat.Length) i = strText.IndexOf(strReplaceWhat) End While Return strText End Function Dim s As String = "Hello, my name is #name# and my friend's name is #name#" s = Replace(s, "#name#", AddressOf RandomName) 'Note: RandomName is your function.
Comments
0 B
|0 👍
/0 👎
0 B
|👍
/👎