
Amy M. answered 03/22/15
Tutor
5.0
(1,583)
CalTech Grad, Software engineer with 30+ years experience.
6) Simplify the following nested If statement to a non-nested if statement.
If (num1 > 10) And (num1 < 20) Then
txtOutput.Text = "The number is in the range "
End If
If (num1 > 10) And (num1 < 20) Then
txtOutput.Text = "The number is in the range "
End If
47) Change the following If block to Select Case statement.
Dim a As Integer = CInt(InputBox("Number"))
Select Case a
Dim a As Integer = CInt(InputBox("Number"))
Select Case a
Case 1
txtOutput.Text = "One"
Case 2 To 10
txtOutput.Text = "Medium"
Case Is >10
txtOutput.Text = "Big"
Case Else
txtOutput.Text = "Negative"
End Select
txtOutput.Text = "One"
Case 2 To 10
txtOutput.Text = "Medium"
Case Is >10
txtOutput.Text = "Big"
Case Else
txtOutput.Text = "Negative"
End Select
48) What will be the output (on txtBox) of the following statements?
1) Dim str As String = "stroll"
str = str.SubString(1) & str.SubString(0,1)
txtBox.Text = str
The output is
trolls
1) Dim str As String = "stroll"
str = str.SubString(1) & str.SubString(0,1)
txtBox.Text = str
The output is
trolls
2) Dim num As Double = 0
Select Case num
Case Is < 10
txtBox.Text = "Small"
Case 0 To 60
txtBox.Text = "Middle"
Case Is <= 100
txtBox.Text = "Big"
Case Else
txtBox.Text = "Wrong Input"
End Select
The output is
Small
3) Dim x, y As Double
x = 2
y = 8
Select Case x + y
Case x To y / x, y
txtBox.Text = "ONE"
Case Is >= x * y, 11
txtBox.Text = "TWO"
Case y – x, 10
txtBox.Text = "THREE"
Case Else
txtBox.Text = "NONE"
End Select
The output is
THREE
4) Dim n1, n2, n3 As Integer
n1 = 5
n2 = 10
n3 = 20
If n1 > n2 And n1 > n3 Then
txtBox.Text = CStr(n1)
ElseIf n2 > n3 Then
txtBox.Text = CStr(n2)
Else
txtBox.Text = CStr(n3)
End If
The output is
20
5) Dim c As String
txtBox.Text = CStr(Asc("A")+7) + CStr(ASC("a")+8)
72105
////////////////
65+7=72
97+8=105
Dim codeInt As Integer
' The following line of code sets codeInt to 65.
codeInt = Asc("A")
' The following line of code sets codeInt to 97.
codeInt = Asc("a")
' The following line of code sets codeInt to 65.
codeInt = Asc("A")
' The following line of code sets codeInt to 97.
codeInt = Asc("a")
4) btnCompute.Text = "Do It!" 'Change the caption of a button