Error during the first macro activation

Error during the first macro activation

Hello!
I need a help again.
An error "Type mismatch" is appeared during first activation of VBA macro in Runtime mode.
It has happened when I tried to convert variable with type of double to string :
b = thisproject.variables.item(i).value
a=str(b)
And when I traced it, the function str() had worked good. And after that macro worked without any mistakes.
How can I execute the macro without this mistake at the first launch?

This is a migrated post! Originally posted on 16.11.2010 by user olga. Please be aware that information can be outdated.