66_1022q_handling_a_common_programming_mistake_f2013

66_1022q_handling_a_common_programming_mistake_f2013 -...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Handling a Common Programming Mistake David Rossiter, Eddie Chan and Oz Lam COMP1022Q Introduction to Computing with Excel VBA VBA Can Automatically Make Variables Usually, when the VBA engine is running some code and finds an unknown variable name, it will automatically create a new variable with that name, and then carry on with the code For example, the variable MyMoney is automatically created in the following code: COMP1022Q Handling a Common Programming Mistake Page 2 MyMoney = 100000 MsgBox MyMoney The variable MyMoney is created automatically here without using a Dim statement Automatic Variable Creation Good or Bad? Because VBA will make variables for you, you can be lazy and not create any variables before you use them i.e. you dont need to use any Dim statement in the code at all! That sounds great but sometimes this can lead to bugs, i.e. mistakes in the code, that are difficult to find In the following example we show a bug that means the money in a bank account is displayed wrongly COMP1022Q Handling a Common Programming Mistake Page 3 An Example of...
View Full Document

Page1 / 9

66_1022q_handling_a_common_programming_mistake_f2013 -...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online