I have a local var
dim lsConfMsg as String
This blows up compiler with [quote]There is more than 1 item with this name and it’s not clear to which it refers[/quote]
lsConfMsg.ToText.Replace(lsConfMsg, "#eduamountpaid#", rs.Field("Cost").StringValue)
And this doesn’t
lsConfMsg = Replace(lsConfMsg, "#eduamountpaid#", rs.Field("Cost").StringValue)
It doesn’t make sense to me, could someone explain this.
Thanks
You are unnecessarily calling the Text version of Replace and giving it a String rather than Text in its second parameter. This confuses and angers the compiler.
Also, the result of a Replace, either as String or Text, must be assigned.
Try either of these instead:
lsConfMsg = lsConfMsg.Replace("#eduamountpaid#", rs.Field("Cost").StringValue)
lsConfMsg = lsConfMsg.ToText.Replace("#eduamountpaid#", rs.Field("Cost").StringValue.ToText)
The second version is for illustration of the point only. As I said, introducing the Text type here is unnecessary and probably slower.
Sometimes I have no idea where my brain went!
Thanks for pointing out the obvious!
DaveS
(DaveS)
May 6, 2016, 8:38pm
4
I hate it when the compiler gets “angry”…
Tim_Hare
(Tim Hare)
May 6, 2016, 8:43pm
5
Worse yet is when you anger the programming gods.