Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Figure (1-6) the code of calculating the area and circumference of a circle

An error message will appear that means that the variable (Radius) and the constant (pi) were
not recognized, where it was declared in the procedure of command button (Button1), and thus we
know that they are undefined in the procedure of command button ( Button2).
And you can make sure of that from the yellow rectangle if you indicate your mouse to the
variable (pi) in the second line, as shown in (1-6):
The yellow rectangle appears when pointing with the mouse to the variable (Pi) in the second
line as shown in figure (1-7):

Figure (1-7) Error Statement in theCode


To solve this problem, we repeat the declaration of the variable (Radius) and the constant (Pi) in the
scope of the Event Procedure (Button2_Click) as shown in figure(1-8).

Figure (1-8) the code after the declaration of the variable (Radius) and the constant (Pi)

Or we declare the variable (Radius) and constant (pi) on the level of class (Form3) and thus we do
not need to declare them on the level of the event procedure for each of the command button
(Button1) or (Button2), as shown in figure (1-9):

10/60

You might also like