Presentation is loading. Please wait.

Presentation is loading. Please wait.

PSU CS 106 Computing Fundamentals II Visual Basic Program Creation HM 1/3/2009.

Similar presentations


Presentation on theme: "PSU CS 106 Computing Fundamentals II Visual Basic Program Creation HM 1/3/2009."— Presentation transcript:

1 PSU CS 106 Computing Fundamentals II Visual Basic Program Creation HM 1/3/2009

2 2 © Dr. Herbert G. Mayer Agenda Assumptions & Preparation VB Terminology A VB Project Hello World Student Repeat Input & Output Student Repeat

3 3 © Dr. Herbert G. Mayer Assumptions & Preparation Have computer with Microsoft ® Operating System Similar steps apply to other OSes, but not addressed here Visual Basic (VB) 2005 --or newer-- is installed With a VB icon, ready for a double-click Have reference text from which to study, e.g. D. Schneider’s An Introduction to Programming Using Visual Basic 2005 –Giving you a mechanism to build a VB project –To Create a VB program –To Run and debug VB program You can learn the syntax rules of VB language proper You understand relationship program to visual Interface Initial difficulties are caused by not understanding the mechanical steps of project creation and program execution, as opposed to understanding the Basic language

4 4 © Dr. Herbert G. Mayer VB Terminology nameMeaning projectIs VB program to edit, debug, run and rerun; has screens for output, buttons to activate event-sub, text boxes for input, etc. Toolbox (left side)List of ~10 VB command groups, e.g. “Command Controls” Main area (mid)Large Windows field, holding Form1 and output space Form1 (in main area)Defined window area in main area, representing modules of main program; holds buttons and text boxes Properties (right side) For selected field, shows list of all attributes, such as r/w/ color, size, font type, font size, location, language etc. buttonnamed VB field on VB Form, used to activate sub msgboxPop-up box showing generated output Event procedure: Sub keyword Similar to procedure/function. Associated with a button, has predefined formal parameter list, named after associated button Button buttonWhen clicked, creates a button on Form1 TextBox buttonWhen clicked, creates a text box on Form1 for input to program F4 keyActivates properties window F5Tries to run a program, compile is hidden, debug program if failure occurs Alt F4Ends program execution, ends debugging

5 5 © Dr. Herbert G. Mayer VB Terminology: Toolbox & Main Area

6 6 © Dr. Herbert G. Mayer VB Terminology: Properties

7 7 © Dr. Herbert G. Mayer VB Terminology: Main VB

8 8 © Dr. Herbert G. Mayer A VB Project: Create New Project Click on VB icon on desktop – Start Page opens Click on File, top left – box with file options opens Click on New – Project & File options open Click on Project – New Project Window opens Pay attention to Name-field and Location-field Recommend: You select a better project name than WindowsApplication1 You see the VB Start Page with the new project So you see on the screen l2r : –Toolbox on the left side of the screen –Main Area in the middle –And Properties on the right side of the screen –Headed by new project name

9 9 © Dr. Herbert G. Mayer A VB Project: Use Previous Project Click on VB icon on desktop – Start Page opens Click on Recent Projects project name of your choice –List is populated with prior project names –One or more You get a VB Start Page with selected project So you see on the screen l2r: –Toolbox on the left side of the screen –Main Area in the middle –And Properties on the right side of the screen –Headed by new project name

10 10 © Dr. Herbert G. Mayer A VB Project: Start Page

11 11 © Dr. Herbert G. Mayer A VB Project: New Project Window

12 12 © Dr. Herbert G. Mayer A VB Project Every button is associated with an Event Procedure –Sub with formal parameter list for –sender As System.Object’ IDE capitalizes 1 st letter –e As System.EventArgs’ of all keywords –Both value parameters; explained later –Clicking on button 1 st time creates skeleton of event procedure! Generally, each text box is associated with an Event Procedure –But input text (and converted result) can be referenced anywhere else too in VB source program –Method to do so, is to use: TextBox1.Text Main program is effectively Form1 with buttons and text boxes Actual VB program also has functions and procedures that can be called, with parameters, and repeatedly To compile, execute, debug: click F5

13 13 © Dr. Herbert G. Mayer Hello World

14 14 © Dr. Herbert G. Mayer Hello World

15 15 © Dr. Herbert G. Mayer Hello World

16 16 © Dr. Herbert G. Mayer Student Repeats: Hello World

17 17 © Dr. Herbert G. Mayer Input & Output Next project –prompts user for numeric input –Then reads the input –Finally performs computation and –Outputs the computed numbers Needs 3 items, generates 1 –Button to prompt for number –Text box to read number from (i.e. stdin file in Unix) –Button to compute and produce output –A fourth item is created: MsgBox for output (i.e. stdout in Unix)

18 18 © Dr. Herbert G. Mayer Input & Output D

19 19 © Dr. Herbert G. Mayer Input & Output

20 20 © Dr. Herbert G. Mayer Input & Output

21 21 © Dr. Herbert G. Mayer Student Repeats: Input & Output


Download ppt "PSU CS 106 Computing Fundamentals II Visual Basic Program Creation HM 1/3/2009."

Similar presentations


Ads by Google