Now suppose that I want a random number between 1 and ten. Therefore we can replace the code behind the Random button with lblAnswer. This is a bit closer to the 1 to 10 range that we need. Scope of Variables Variables may either global or local. So far, the variables we have defined are known only to the subroutine they were defined in.
Global variables are know to all of the objects on the form.
They are declared in the General Declarations section using the Private keyword instead of Dim. Global constants are also declared in General Declarations using the General Declarations keyword. The series of steps used to solve a problem is called an algorithm. Develop a program that plays a number guessing game between the user and the computer. Therefore, the variable for the random number is declared in the General Declarations section.