Tuesday 23 June 2020

29 - Web Designing Question - 09


 

What is the correct statement when declaring and assigning the value of 100 to an integer variable called numPeople in Visual Basic?

(A)    Dim numPeople =100

(B)    Dim numPeople = Int (100)

(C)    numPeople = 100

(D)   Dim numPeople As Integer = 100


Variable Declaration in VB.Net

The Dim statement is used for variable declaration and storage allocation for one or more variables. The Dim statement is used at module, class, structure, and procedure or block level.

Some valid variable declarations along with their definition are shown here –

Dim StudentID As Integer

Dim StudentName As String

Dim Salary As Double

Dim count1, count2 As Integer

Dim status As Boolean

Dim exitButton As New System.Windows.Forms.Button

Dim lastTime, nextTime As Date

Variable Initialization in VB.Net

Variables are initialized (assigned a value) with an equal sign followed by a constant expression. The general form of initialization is −

variable_name = value;

For example,

Dim pi As Double

pi = 3.14159

You can initialize a variable at the time of declaration as follows −

Dim StudentID As Integer = 100

Dim StudentName As String = "Ram"

 

 

So here correct answer is option (D) i.e.

Dim numPeople As Integer = 100 

No comments:

Post a Comment