In: Computer Science
For each of the following Visual Basic code snippets, identify the syntax error.
If intX > 100 lblResult.Text = "Invalid Data" End If
Dim str As String = "Hello" Dim intLength As Integer intLength = Length(str)
If intZ < 10 Then lblResult.Text = "Invalid Data"
Dim str As String = "123" If str.IsNumeric Then lblResult.Text = "It is a number." End If
Select Case intX Case < 0 lblResult.Text = "Value too low." Case > 100 lblResult.Text = "Value too high." Case Else lblResult.Text = "Value just right." End Select
Syntax Error Detection and correction
'Syntax error detect and change --> Declare X and Z as
integer
Dim X As Integer =
0
Dim Z As Integer =
0
If X > 100 Then
lblResult.Text = "Invalid Data"
End If
Dim str As String =
"Hello"
Dim intLength As
Integer
'Syntax error detect and
change --> Length method call
intLength =
str.Length()
If Z < 10
Then
lblResult.Text = "Invalid Data"
End If
'Syntax error detect and
change --> Dstr already declared so inititalize
str = "123"
If IsNumeric(str)
Then
lblResult.Text = "It is a number."
End If
'Syntax error detect and
change --> Select case arrangement
Select Case X
Case < 0
lblResult.Text = "Value too low."
Case > 100
lblResult.Text = "Value too high."
Case Else
lblResult.Text = "Value just right."
End Select