Hello,
This is a bizarre one. I've got some Macro code in Excel, and variables are getting initialised to the last value they were when the code was last run! Before the code even reaches them!
I thought I was imagining things, but I've had it happen three times now. I've tried closing Excel and re-opening, but it still happens. The only thing that works is if I restart the PC.
If I put a break point before a line where a variable gets set for the first time, when I hover my mouse over the variable, there is already a value assigned to it (the example was a Long that I declare, then two lines later set to 2; it was already set to 4 on the line before the assignment).
I know with older languages you had to be careful of remnant values in memory when declaring variables, but I didn't think that was the case with VBA.
Here are the versions:
MS Office Excel 2003 (11.8169.8172) SP3
Windows XP Pro Version 2002 SP2
Has anybody else experienced this occurring? Does this mean I always have to initialise variables explicitly?
Regards,
Rob.
This is a bizarre one. I've got some Macro code in Excel, and variables are getting initialised to the last value they were when the code was last run! Before the code even reaches them!
I thought I was imagining things, but I've had it happen three times now. I've tried closing Excel and re-opening, but it still happens. The only thing that works is if I restart the PC.
If I put a break point before a line where a variable gets set for the first time, when I hover my mouse over the variable, there is already a value assigned to it (the example was a Long that I declare, then two lines later set to 2; it was already set to 4 on the line before the assignment).
I know with older languages you had to be careful of remnant values in memory when declaring variables, but I didn't think that was the case with VBA.
Here are the versions:
MS Office Excel 2003 (11.8169.8172) SP3
Windows XP Pro Version 2002 SP2
Has anybody else experienced this occurring? Does this mean I always have to initialise variables explicitly?
Regards,
Rob.
Comment