Answer to Question #50433 in Visual Basic for Bender

Question #50433
Which of the following statements about If statements is not true?

a. An If statement is the Visual Basic implementation of the selection structure.

b. An If statement can have an unlimited number of ElseIf clauses.

c. Every If statement must include an Else clause.

d. You can nest If statements within the If, ElseIf, or Else clauses of other If statements.
1
Expert's answer
2015-01-21T02:52:11-0500
Is not true: C

Causes:
a. The selection control structureallows one set of statements to be executed if a condition is true and another
set of actions to be executed if a condition is false.
b. If statement can have anunlimited number of ElseIf clauses because every new part of elseif is
described as new if statement on else
Example:
If i = 0 Then
MsgBox ("i=0")
ElseIf i = 1 Then
MsgBox ("i=1")
ElseIf i = 2 Then
MsgBox ("i=2")
End If
c. Every If statement don’t mustinclude an Else clause (You can use only if condition)
Example:
If dblTotalSales > 100000 Then
dblBonusAmount = 500
End If
d. Statements «if» can havean unlimited nesting.
Example:
If strShiftCode = "1" Then
sngShiftRate = sngHourlyRate
Else
If strShiftCode = "2" Then
sngShiftRate = sngHourlyRate * 1.1
ElseIf strShiftCode = "3" Then
sngShiftRate = sngHourlyRate * 1.15
Else
Print "Shift code error"
End if
End If

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS