B
bradsalmon
Hi all,
Been looking at this problem for a a couple of days and just can't
figure out what is going on here.
The below is a simple version of my code that produces the same
strangeness on my computer in Access, but I'm pretty sure it would be
the same no matter which program it was done through -
Public Sub mytest()
Dim mysection As String
mysection = "test & test1"
Debug.Print myreserves(mysection)
End Sub
Private Function myreserves(mystr As String) As String
Dim i As Long
i = InStr(1, mystr, Chr(38))
Do While i > 0
mystr = Left(mystr, i - 1) & "&" & Right(mystr, Len(mystr) -
i)
i = InStr(i + 1, mystr, Chr(38))
Loop
myreserves = mystr
End Function
When running mytest I can understand why I get a debug print of "test
& test1" but if you step through the code and look at the
variables before the sub ends you see that mysection is set to "test
& test1" as well - why is that? Surely this string should stay as
"test & test1"?
Or am I missing something really obvious here?
Thanks,
Brad
Been looking at this problem for a a couple of days and just can't
figure out what is going on here.
The below is a simple version of my code that produces the same
strangeness on my computer in Access, but I'm pretty sure it would be
the same no matter which program it was done through -
Public Sub mytest()
Dim mysection As String
mysection = "test & test1"
Debug.Print myreserves(mysection)
End Sub
Private Function myreserves(mystr As String) As String
Dim i As Long
i = InStr(1, mystr, Chr(38))
Do While i > 0
mystr = Left(mystr, i - 1) & "&" & Right(mystr, Len(mystr) -
i)
i = InStr(i + 1, mystr, Chr(38))
Loop
myreserves = mystr
End Function
When running mytest I can understand why I get a debug print of "test
& test1" but if you step through the code and look at the
variables before the sub ends you see that mysection is set to "test
& test1" as well - why is that? Surely this string should stay as
"test & test1"?
Or am I missing something really obvious here?
Thanks,
Brad