100 likes | 129 Views
Discover the concepts of sequential and selection control structures in Visual Basic programming through examples of if-then, nested selection, and alternative versions. Explore the select case and repetition concepts presented by Dr. John Abraham, a professor at UTPA. Learn loop structures like while-end, do-while-loop, do-until-loop, for-next, do-loop tasks. Enhance your understanding with practical examples and assignments explained in detail.
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