I am relatively new to VBA. I have had no formal training and I do not expect to get any in the near future.
Is it bad to declare a variable inside an if then statement?
for example:
if x = 1 then
Dim Series1
Set Series1 = operatorChart.SeriesCollection.Add
end if
Set Series1 = Nothing
Is it legal to set a variable declared in an if then statement to nothing outside of the statement. I do not get any compiler errors, but will this cause "issues" with my code?
Along the same lines... I using a database and a connection to the database. Any advice on how to properly handle these items... do I need to close them? or just set them = Nothing.
If an experienced programmer knows of good resources I could read I would appreciate it. Also, if they could describe a few of the practices they try to follow when handling certain issues... I would appreciate it.
Is it bad to declare a variable inside an if then statement?
for example:
if x = 1 then
Dim Series1
Set Series1 = operatorChart.SeriesCollection.Add
end if
Set Series1 = Nothing
Is it legal to set a variable declared in an if then statement to nothing outside of the statement. I do not get any compiler errors, but will this cause "issues" with my code?
Along the same lines... I using a database and a connection to the database. Any advice on how to properly handle these items... do I need to close them? or just set them = Nothing.
If an experienced programmer knows of good resources I could read I would appreciate it. Also, if they could describe a few of the practices they try to follow when handling certain issues... I would appreciate it.