I have this code,
Dim str As String, Dim replaceStr As String, Dim counter as Integer
str = "I have the number 3"
For counter = 1 To 5
replaceStr = Replace(str, counter, 99)
Next counter
I want the replace function to catch when the counter = 3 so that it replaces the 3 with 99.
So far I am still getting "I have the number 3".
I have tried Replace(str, CStr(counter), 99) and still gives me the same results.
Dimon the first line is a syntax errorreplaceStrAFTER the for loop completes you will haveI have the number 3because the LAST iteration of the FOR loop was number "5". Instead, tossdebug.print replaceStrINSIDE your FOR loop and rerun. You'll see 5 lines printed to your immediate pane and the third will properly readI have the number 99as you expect.