100 likes | 128 Views
Control Structures in VB. Dr. John Abraham Professor, UTPA. Sequential vs Selection. Program Counter Transfer of control Goto unstructured Structured: sequence, selection and repetiton. Selection. If..then If grade >= 60 then write(“Passed”) else write (“Failed”) End If.
E N D
Control Structures in VB Dr. John Abraham Professor, UTPA
Sequential vs Selection • Program Counter • Transfer of control • Goto unstructured • Structured: sequence, selection and repetiton
Selection • If..then • If grade >= 60 then write(“Passed”) else write (“Failed”) End If
Nested selection If grade >= 90 then write(“A”) Else if grade >= 80 then write(“B”) Else if grade >= 70 then write(“C”) Else write(“F”) End If End If End If
Alternative version If grade >=90 then write (“A”) ElseIf grade >=80 then write(“B”) ElseIf grade >= 70 then write(“C”) Else write(“D”) End If
Select Case Select Case Grade Case 100 statements Case 90 to 99 statements Case 80 to 89 statements Case 70 to 79 statements Case Else statements End Select
Repetition chapters 5 & 6 While – End While Do While – Loop Do Until – Loop For – Next Do – Loop While Do – Loop Until See example programs
While – End While • Select a loop control variable (example grade) • Initialize that variable (either read or assign) • Set up loop like this While grade <= 100 Grade = console.readline() End while