Presentation is loading. Please wait.

Presentation is loading. Please wait.

Illuminating Computer Science CCIT 4-6Sep

Similar presentations


Presentation on theme: "Illuminating Computer Science CCIT 4-6Sep"— Presentation transcript:

1

2 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/

3 Introduction to Programming Concepts Visual Basic: an Introduction Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/

4 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/Objectives The audience should be familiar with the Visual Basic Environment. The audience should be able to build simple Visual Basic Applications. The audience should learn the precedence rules for writing equations. The audience should be able to write programs using control structures

5 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Performing a Task on the Computer Determine Output Identify Input Determine process necessary to turn given Input into desired Output

6 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Problem-solving approach like algebra class How fast is a car traveling if it goes 50 miles in 2 hours? Output: a number giving the rate of speed in Km per hour Input: the distance and time the car has traveled Process: rate = distance/time

7 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Pictorial representation of the problem solving process

8 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Program Planning Tips Always have a plan before trying to write a program The more complicated the problem, the more complex the plan must be Planning and testing before coding saves time coding

9 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Simplified Program development cycle 1. Analyze: Define the problem. 2. Design: Plan the solution to the problem. 3. Choose the interface: Select the objects (text boxes, buttons, etc.).

10 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Program development cycle continued 4. Code: Translate the algorithm into a programming language. Try to avoid jumping straight to this step, which can result in a sloppy solution! 5. Test and debug: Locate and remove any errors in the program. 6. Complete the documentation: Organize all the material that describes the program.

11 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ What is Visual Basic? High Level 4th Generation Programming Language Object and Event Driven Visual - Windows Based Integrated Development Environment or IDE

12 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ What is VB Used For? Most Popular Programming Language Stand alone programs Applets that can be run on many different kinds of computers Customized specialized Applications –E- Commerce Web based shopping forms and inquiries User friendly Interface to applications

13 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/  Used by a computer equipment retail outlet to record data regarding customer orders. Example Order Entry Screen Allows user to use a mouse to click on boxes for text entry. Also enables user to click on buttons to initiate processing steps.

14 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Generations of Computer Languages 1st - Machine language - 0110 0011 1000 2nd - Procedure-oriented languages –FORTRAN - 1954 for scientists and engineers –COBOL - 1959 for business applications –C - 1972 - for UNIX operating systems 3rd - Object-oriented languages 4th - Event-driven languages - i.e.VB 5th - Natural languages i.e. English

15 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Compiler Vs Interpreter Higher Languages are translated to Machine Language by: –Interpreter Translates instructions to machine code line-by-line. BASIC, Quick Basic, Visual Basic –Compiler Translates the entire program to machine code before running it. Fortran, C, C++, Visual Basic is also a compiler

16 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ What are the Objects in VB? Pre-programmed Code for: –Command Buttons –Labels –Pictures –Text Boxes Have both data and procedures wrapped together

17 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ What are the Events? –Visual Basic “watches” what the user does –A user activity is called an event –Events include mouse clicks and moves, menu selections, button presses, etc. –Sections of code are only executed in response to an event

18 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ What is the Integrated Development Environment (IDE)?

19 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Visual Basic Environment GUI (Graphical User Interface) - forms and windows that the user sees Property - a characteristic or attribute of an object such as color and size Event - a user action such as clicking a button Code Editor window - editor specially designed to help you when writing code

20 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Visual Basic Environment Components of the VB design environment (Form view)

21 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Visual Basic Environment Components of the VB design environment (Code view)

22 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ The Code Editor Window Object List Box Procedure List Box Auto List Members Full Module View button

23 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ The Code Editor Window Help window Error message box Syntax error in Red Procedure view button

24 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ VB Environment: Project Window The Project Window can be used to navigate between the code and form window for each form / window a project has

25 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ VB Environment: Menu Bar The Menu Bar consists of 3 elements the –Title Bar, which holds the name of application, default if Microsoft Visual Basic [design] –Menu Bar, this is the link to Visual Basics menu facilities, each menu option drops down into sub-menus –Toolbar, contains icons which give access to the more commonly used commands (which are also available through the menu bar) Title barMenu BarToolbar

26 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ VB Environment: Properties Window Used to set how a control looks and behaves Holds its default values

27 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ VB Environment: Control Toolbox Pointer Label Group Frame Check Box Combo Box Horizontal Scroll Bar Timer Directory List Box Shape Image OLE Picture Text Box Command Button Option/Radio Button List Box Vertical Scroll Bar Drive List Box File List Box Line Data Control

28 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ VB Environment: Context Sensitive Help Context sensitive help is very useful Select the item control that you want help on Press the F1 key F1

29 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ The File Menu Project commands Make executable commands Most recent project list Exit command

30 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ The File Menu New Project Open Project Add Project Remove Project Save Project Save Project As Save Component Save Component As Print Print Setup

31 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ The File Menu Template - particular pattern for a project or a project element; start a project from a template saves time Existing tab - displays VB projects Recent tab - displays most recently accessed projects Project Groups - a collection of several projects

32 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Building Your First Application There are three primary steps in building a Visual Project: –Place (or draw) controls on the form. –Assign properties to the controls. –Write event procedures for the controls.

33 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Project Files vbp extension = Visual Basic Project – file that tracks all components frm extension = Form file –separate file for each form frx extension = Binary form file –cannot be read by humans vbw extension = Visual Basic workspace

34 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Starting Visual Basic

35 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Choosing Project Type

36 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Placing Controls on the Form: Image

37 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Assigning Properties to Controls

38 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Adding an Image

39 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Browse for an Image

40 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Image Displayed

41 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Buttons and Text Boxes

42 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Changing the Form Title

43 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Writing the Code (Events)

44 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Writing the Code (Events)

45 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Running the Application

46 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Running the Application

47 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ More Complex Structures

48 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Syntax Boxes Syntax for a Visual Basic statement is shown in a syntax box Reserved words are shown in bold Programmer named words are shown in italics

49 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ The Sub Statement Private Sub controlname_eventname( ) Statements End Sub Where Private is the default procedure type Sub indicates beginning of procedure controlname is name of associated control _ (underscore) required separator eventname is name of corresponding event ( ) set of parentheses is required End Sub indicates end of a procedure

50 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ The Sub Statement Example Private Sub cmdCalcTriangle_Click Dim Base As Single Dim Height As Single Area = 1 / 2 * (Base * Height) End Sub

51 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Declarations, Variables, and Constants Variable - a uniquely named storage location that contains data that changes during program execution Constant - a uniquely named storage locations that contains data that does not change during program execution

52 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Declarations, Variables, and Constants Rules for Naming Variables –Must begin with an alphabetic character –Can’t contain a period or type-declaration characters such as %, &, !, #, @ or $ –Must be unique with same scope –Must be no longer than 255 characters –Should not reserved word (See Appendix A)

53 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Declaring Variables Declaration statement - nonexecutable code that sets aside storage locations for future use Local variables - declared within a procedure or function Global variables - declared in the general section of the application

54 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Declaring Variables Declare variables using the Dim or Static statements Dim statement - value of variable preserved only until procedure ends Static statement - value of variable preserved the entire time the application is running

55 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ The Dim Statement Dim variablename As datatype Where Dim is required variablename should be a descriptive name As is required datatype is one of the following types: Boolean, Byte, Date, Integer, Long, Single, Double, Currency, String, Object or Variant

56 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Declaring Variables Data Types –Boolean - True or false –Date - From Jan 1, 100 to Dec 31, 9999 –Integer - Numbers without a decimal point –Long - Long integer –Single - Numbers with a decimal point –Double - Long Single –Currency - Dollar amounts –String - Character and alphanumeric data –Object - Any object reference such as Word document –Variant - default, can hold any data type

57 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Assigning Values to Variables Variablename = value Where variablename is the descriptive name of the variable = is the assignment operator value is the value the variable will contain Examples: Number1 = 5 FirstName = “Steve” LoanAmount = 67.38 Length = 17.8 Note: Order is important. Variable name always on the left, and value on the right.

58 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Declaring Constants Const constantname As datatype = value Where Const is required constantname is the descriptive name of the constant As is required datatype is the type of data the constant will contain = is the assignment operator value is the value of the constant Examples: Const Pi As Single 3.14159265358979 Const MaxNumber As Integer = 100

59 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/Functions Function - unit of code that returns a value Built-in Functions –Sqr - square root –Rnd - random number generator –Int - returns integer portion of a number –Val - converts a string to a value –Str - converts a value to a string

60 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Application 1: Calculate the area of a circle Inputs: radius of the circle r Output: area of the circle Process: Area=

61 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Application 1: Calculate the area of a circle (Form View)

62 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Application 1: Calculate the area of a circle (Code View)

63 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Application 1: Calculate the area of a circle (Run)

64 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Precedence Table Operator ( ) ^ *, / +,- If precedence of two following operators is equal, then the evaluation starts from left to right.

65 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Simple Examples of Equations Equation in normal form: –Y=3X –Y=X-10+3(X-Z) –Y=X^2*10 –Y= Equation in VB form: –Y=3*X –Y=X-10+3*(X-Z) –Y=X*X*10 –Y=SQR(X)

66 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Application 2: Convert from Fahrenheit Degree to Celsius Original formula: Celsius=5/9(Fahrenheit-32) Visual Basic formula: Celsius=5/9*(Fahrenheit-32) Input: Fahrenheit Output: Celsius Process: Celsius=5/9*(Fahrenheit-32)

67 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Application 2: Convert from Fahrenheit Degree to Celsius (Form View)

68 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Application 2: Convert from Fahrenheit Degree to Celsius (Code View)

69 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Application 2: Convert from Fahrenheit Degree to Celsius (Run)

70 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Application 3: The Wind Chill Application Write a program that calculates the wind chill temperature Inputs: Wind Speed and Temperature Outputs: Wind Chill Temperature

71 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Application 3:The Wind Chill Application Original formula –WC = 0.0817(3.71(V **0.5) + 5.81 - 0.25V)(T - 91.4) + 91.4 Visual Basic statement –WC = 0.0817 * (3.71 * Sqr(V) + 5.81 -(0.25 * V)) * (T - 91.4) + 91.4 Output: Wind Chill (WC) Input 1 T: Temperature Input 2 V: Wind Speed

72 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Adding Controls and Changing their Properties

73 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Writing the Code

74 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Running the Application

75 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Control Structures

76 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Controlling your Application Sequence Selection –If...Then...Else statement –Select Case statement Repetition –For...Next Loop statement –For Each...Next statement –Do Loops

77 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Selection If..Then..Else If (condition) Then (statement[s]) [ElseIf (condition) Then (statement[s])] [Else (statement[s])]

78 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Selection Application: Convert from Numerical Grade to Letter Grade Input: a numeric grade between 0 and 100 Output: depends on input InputOutput 0  49F 50  52D 53  56D+ 57  60C- 61  64C 65  69C+ 70  74B- 75  79B 80  84B+ 85  89A- 90  100A

79 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Selection Application: Convert from Numerical Grade to Letter Grade (Form View)

80 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Selection Application: Convert from Numerical Grade to Letter Grade (Code View)

81 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Selection Application: Convert from Numerical Grade to Letter Grade (Run)

82 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ For...Next Loop Structure For counter = start To end Step increment statements Next counter Where Counter is tested to see if less than end. If so, repeat loop again. If not, go to statement after Next.

83 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Do While...Loop Structure Do While condition statements Loop Where The condition is tested, and if true the loop is repeated. When the condition is false, the loop statements are skipped the statement after Loop is executed.

84 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Do Until...Loop Structure Do Until condition statements Loop Where The condition is tested, and if false the loop is repeated. When the condition is true, the loop statements are skipped the statement after Loop is executed.

85 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Loops Application: Factorial Factorial (N)= N*(N-1)*(N-2)……….*(1)

86 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Factorial Flowchart (N>0)

87 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Factorial Application: Form View

88 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Factorial Application: Code View Using For..Next Loop

89 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Factorial Application: Code View Using Do..While..Loop

90 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Factorial Application: Code View Using Do..Until..Loop

91 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/ Factorial Application: Run

92 Illuminating Computer Science CCIT 4-6Sep http://www.aast.edu/en/colleges/ccit/cs4hs/http://www.aast.edu/en/colleges/ccit/cs4hs/Summary After the completion of this lecture, the audience should be familiar with the visual basic environment and different controls. The audience should be able to write simple programs and generate simple VB applications.


Download ppt "Illuminating Computer Science CCIT 4-6Sep"

Similar presentations


Ads by Google