when we declare the variable in . . . . . . . . of VB then it is public variable

[amp_mcq option1=”static” option2=”public” option3=”local” option4=”general” correct=”option3″]

The correct answer is: C. local

A local variable is a variable that is declared inside a procedure or function. It is only accessible within that procedure or function.

A static variable is a variable that is declared outside of any procedures or functions. It is accessible from all procedures and functions in the class.

A public variable is a variable that is declared with the Public keyword. It is accessible from all procedures and functions in all classes 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 procedure MySub. It is only accessible from within MySub.

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 outside of any procedures or functions. It is accessible from all procedures and functions in the class MyClass.

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 procedures and functions in all classes in the project.

Exit mobile version