Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi, I need help for my Visual Basic class. 1) True or False: : The most common s

ID: 3801763 • Letter: H

Question

Hi, I need help for my Visual Basic class.

1) True or False: : The most common selection statement is the If-Then-Else.

2) What appears in the Msgbox when this is run:

If 1=2 Then
If 2=3 Then
Msgbox("Ok")
Else
Msgbox("Not Ok")
End If
Else
If 2=2 Then
Msgbox("Ok")
Else
MsgBox("Not Ok")
End If
End If

3)

What is in sString at the end of this code:

Dim sString as String
Dim iIndex as Integer = 10

sString ="Unknown"
Select Case iIndex
Case Is < 4
    sString = "Small"
Case Is < 1
    sString = "Large"
Case Else
    sString = "Huge"
End Select

4) True or False: The conditional in the IF statement is evaluated to be either True or False

5) What is in sString at the end of this code:

Dim sString as String
Dim iIndex as Integer = 5
sString = "Unknown"

Select Case iIndex
Case Is <= 4
sString = "Small"
Case Is >= 6
sString = "Large"
End Select

6) What appears in the Messagebox when this is run:

If 5 > 4 And 4 > 5 Then
Msgbox("Ok")
Else
Msgbox("Not Ok")
End If

7)

Which of the following is not legal syntax for an IF statement (Note Answer with letter A,B,C,or D only):

A) If a > b Then .intX = 100

B) If a > b Then intX = 200 End If

C) If a > b Then intX = 100 Else .intX = 200 End If

D) If a > b .intX = 100 End If

8) True or False: Select Case construct is used for iteration in a loop

9) True or False Another form of the IF statement is to use ElseIf in place of Else

10) True or False: The Select Case statement is preferred to using a series nested ElseIf

Explanation / Answer

1) True or False: : The most common selection statement is the If-Then-Else.

Ans) True

The most common selection statement in any programming language is if-then-Else statement. It checks the given condition and does what we write in the statement block if it satisfies otherwise proceed with the else block statements.

2) In this the msg box displays Ok

First the condition 1=2 is checked because the condition not satisfies the execultion comes to the Else block rather than the second if statement. Now the execution is in the Else block if statement 2=2, the condition is satifued here so it prints the Ok message.

3) The sString contains Huge at the end of the code.

Here the sString has the value 10, the condition checking in the case statements is <4 and <1. so it obviously goes to the case else so it prints Huge.

4) True

The condition in the If statement evaluates to either true or false and the proceed to the next statements or block based on the given conditions which we implemented that what had to be done if condtion is false or true.

5) The sString contains Unknown at the end of the code

Because here in the case statement the condition which is checking is upto the value <=4 and then from >=6 but here sString has value 5 which doesnot have any condition to check here so it prints only Unknown.

6) For this the message box prints message Ok.

Because here the condition is 5>4 and 4<5 which is true , so Ok will printed.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote