1 / 34

CSCI110 Event-Driven Programming with Visual Basic

CSCI110 Event-Driven Programming with Visual Basic. Fundamentals 1. Problem Solving and Computer Programming. Algorithms Program Design Software Lifecycle. Algorithms. An algorithm is a sequence of precise instructions (written in English) that leads to the solution to a problem.

susan
Download Presentation

CSCI110 Event-Driven Programming with Visual Basic

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSCI110 Event-Driven Programming with Visual Basic

  2. Fundamentals 1

  3. Problem Solving and Computer Programming Algorithms Program Design Software Lifecycle

  4. Algorithms An algorithm is a sequence of precise instructions (written in English) that leads to the solution to a problem. An algorithm can be compared to a recipe to bake a cake, a set of directions to enroll for a class or a set of instructions to install an operating system...

  5. Start Flowchart of a program to calculate the average of 3 numbers input 3 numbers calculate total divide total by 3 output result End

  6. input the numbers calculate the total calculate the average output the result Pseudocode of a program to calculate the average of 3 numbers

  7. Hierarchy chart of a program to calculate the average of 3 numbers Calculate average of 3 numbers print out the result divide the total by 3 input the numbers calculate the total

  8. Software Lifecycle 1. Problem definition 2. Algorithm design 3. Coding 4. Testing 5. Maintenance

  9. Visual Basic Objects Visual Basic Events Numbers Strings Input and Output Built-In Functions

  10. Visual Basic Objects Visual Basic Events Numbers Strings Input and Output Built-In Functions

  11. Visual Basic Objects Visual Basic programs use a Windows style screen called a form. On the form are placed text boxes for the user to type in text, and command buttons for the user to press.

  12. Text boxes and buttons are examples of controls.

  13. Forms and controls are called objects.

  14. The most commonly used VB objects (aka controls): Text Box Command Button Label Picture Box

  15. The Text Box A Text Box Walkthrough Page 43 of the textbook

  16. The Command Button A Command Button Walkthrough Page 49 of the textbook

  17. The Label A Label Walkthrough Page 50 of the textbook

  18. The Picture Box A Picture Box Walkthrough Page 51 of the textbook

  19. Visual Basic Objects Visual Basic Events Numbers Strings Input and Output Built-In Functions

  20. Visual Basic Events When a VB program is running, a form and its controls appear on the screen. Nothing happens until the user interacts with the form or its controls in some way, such as clicking on a button. Such an interaction is known as an event.

  21. What is an Event? Examples: • Click a button • Double click a button • Changing text in a text box anything that happens to an object (aka control) is an event

  22. The 3 steps to creating a VB program: 1. Create the user interface (form, buttons). 2. Set the properties of the objects. 3. Write the code that executes when the events occur.

  23. The 3 steps to creating a VB program: 1. Create the user interface (form, buttons). 2. Set the properties of the objects. 3. Write the code that executes when the events occur.

  24. When you are in the program design mode of VB, and you perform some action on an object such as clicking on a command button on your form, a code window opens up with some code already supplied for you . . .

  25. . . . the content of the supplied code will depend on which object you clicked on . . .

  26. The statements to be executed when an event occurs are written in a block of code known as an event procedure. The structure of an event procedure is: Private Sub objectName_event()‏ statements End Sub

  27. The word Sub in the first line signals the beginning of the event procedure, and identifies the object and the event occurring to that object… Private Sub objectName_event()‏

  28. The last line (End Sub) signals the end of the event procedure. The statements to be executed appear between these two lines...

  29. Private Sub objectName_event()‏ statements End Sub

  30. The word Private means that this event procedure cannot be invoked (made to execute) by an event from another form. This will not concern us until much later in the course when we use multiple forms.

  31. An example event procedure Private Sub cmdButton_Click()‏ txtBox.Text = " " End Sub this event procedure clears the contents of the text box when the button is clicked . . .

  32. Homework • Read pages 41 - 70 of the textbook

  33. End of VB_Fundamentals1.ppt

  34. Last updated: Mon 29 Dec 2008, 13:37 PT, AHD

More Related