Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement