Logical & Syntax Errors

Here is the pseudo code and VBE code we used today.

If Percent<45 Then
Display Fail
Elseif  Percent>=45  Then
Display D
Elseif  Percent>=50 then
Display C
Elseif  Percent>=60 then
Display B
Elseif Percent>=75then
Display A
Else
Display “Error”
End IF
VB Code

Dim Percent As Integer

Percent = InputBox(“Please enter the percentage”)

If Percent >= 75 Then

MsgBox(“A”)

ElseIf Percent >= 60 Then

MsgBox(“B”)

ElseIf Percent >= 50 Then

MsgBox(“C”)

ElseIf Percent >= 45 Then

MsgBox(“D”)

ElseIf Percent < 45 Then

MsgBox(“Fail”)

Else

MsgBox(“Error”)

End If

Remember the last Else is a error trap and if your program works correctly you should never see it.