Download presentation
Presentation is loading. Please wait.
1
Visual Basic I Programming
CSC 162 Visual Basic I Programming
2
Elements of a Program Prologue (or Heading) Global declarations
Functions / Procedures Event procedures
3
Prologue Program Name Author Date Course/Section Program Description:
The first line is a general description of the programs purpose. The remaining lines give detail about the program One Blank Line Pseudocode A detailed guide on how to format the pseudocode will be provided next
4
Pseudocode Not a real programming language
Combination of English and code-like statements Consists of only executable statements Allows for designing structured programs Can then be turned into actual computer code
5
Pseudocode Style In sequence and level of detail No blank lines
Should match code exactly (not mean line for line) In sequence and level of detail No blank lines Start with: BEGIN Program Name Finish with: END Program Name Indentation After every flow control statement and after BEGIN Always indent 3 spaces Use all capital letters for flow control words (IF, ELSE, FOR, WHILE, BEGIN, and END) All Flow control statements need an END Statement after an END should line up with that END Each END should line up with its beginning (Un-indent)
6
Prologue Example ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 'Program Name: Test Average 'Author: Timothy D. Stedman 'Date: September 2003 'Course/Section: CSC 'Program Description: ' This program is designed to determine the average of three test ' scores. The user will enter the values into three text boxes. ' When the "Calculate" button is pressed, the program will compute ' the average and display the results in a label. When the user ' presses the "Exit" button, the program will end. ' 'BEGIN Test Average ' Input three grades ' Compute average of the test grades ' Display the average 'END Test Average
7
Comparison Operators = Equal <> Not equal < Less than >
Greater than <= Less than or equal >= Greater than or equal
8
Logical Operators Not Negation And Logical and Or Logical or
9
If Structures If/Then If/Then/Else If/Then/ElseIf
10
If/Then If intGrade < 65 Then Print "Fail" End If
11
If/Then/Else If intGrade >= 65 Then Print "Pass" Else Print "Fail"
End If
12
If/Then/ElseIf If sngGPA >= 3.9 Then Print "Summa Cum Laude"
ElseIf sngGPA >= 3.7 Then Print "Magna Cum Laude" ElseIf sngGPA >= 3.5 Then Print "Cum Laude" Else Print "No graduation honors" End If
13
InputBox Function InputBox(Prompt, Title)
The value from the InputBox needs to be assigned to a variable. intGrade = Val(InputBox("Enter grade", "Grade"))
14
Pseudocode Problems Description: Input three numbers and print them out in ascending order Description: Input three sides of a triangle. Display a message indicating if the the three sides can actually for a triangle or not. Description: Input three sides of a triangle and determine if the three sides from a right triangle, an isosceles triangle or an equilateral triangle. Description: Input the number of minutes parked in a parking garage. Determine and display the number of hours parked. If the vehicle is parked for any part of an hour, it is charged for the entire hour. Description: Input one exam score. Check to see if the exam score is between 0 and 100. Print a message indicating the exam score is in range or out of range.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.