Home » mcq » Visual basic » when we declare the variable in a Particular control of vb then it is . . . . . . . . variable .
static
public
local
general
Answer is Wrong!
Answer is Right!
The correct answer is: C. local variable
A local variable is a variable that is declared inside a function or procedure.
64 288 64 288 64S117.2 64 74.6 75.5c-23.5 6.3-42 24.9-48.3 48.6-11.4 42.9-11.4 132.3-11.4 132.3s0 89.4 11.4 132.3c6.3 23.7 24.8 41.5 48.3 47.8C117.2 448 288 448 288 448s170.8 0 213.4-11.5c23.5-6.3 42-24.2 48.3-47.8 11.4-42.9 11.4-132.3 11.4-132.3s0-89.4-11.4-132.3zm-317.5 213.5V175.2l142.7 81.2-142.7 81.2z"/>
Subscribe on YouTube
It is only accessible within that function or procedure.
A static variable is a variable that is declared outside of any functions or procedures. It is accessible from all functions and procedures in the class.
A public variable is a variable that is declared with the Public
keyword. It is accessible from all code in the project.
A general variable is not a valid option.
Here is an example of a local variable:
Sub MySub()
Dim x As Integer
x = 10
End Sub
In this example, the variable x
is declared inside the MySub
procedure. It is only accessible from within that procedure.
Here is an example of a static variable:
Class MyClass
Private x As Integer
Public Sub MySub()
x = 10
End Sub
End Class
In this example, the variable x
is declared inside the MyClass
class. It is accessible from all methods in the class.
Here is an example of a public variable:
Public x As Integer
In this example, the variable x
is declared with the Public
keyword. It is accessible from all code in the project.