Download presentation
Presentation is loading. Please wait.
Published byRudolph Kelley Modified over 8 years ago
1
Chapter Two Creating a First Project in Visual Basic
2
Learning Objectives Identify the elements of the Visual Basic development environment, including the title bar, menu bar, toolbar, initial form window, Toolbox, Project Explorer window, Properties window, and Form Layout window. Create a form in a Visual Basic project. List and differentiate between common controls such as labels, textboxes, and command buttons used in Visual Basic and their properties. Create an interface on the form using elements such as labels, command buttons, and image controls from the Toolbox
3
Learning Objectives Define what a message box is and how to use one for output from a project Use the Code window to write the event procedure for a command button Identify the different types of files that make up a Visual Basic project and be able to save a project to disk Identify flowcharting symbols and create a simple flow chart Access and use the MSDN Help from a web page
4
Getting Started with Visual Basic Double-click VB icon on Desktop or use Start|Programs|Visual Basic to bring up opening dialog box
5
VB Development Environment You should start in the default MDI environment Project Window should have a white background Form Window is shown as part of a larger in Project Window **** Maximize Project Window
6
VB Development Environment Program Design Mode Project Explorer Properties Window Form Layout Window Initial Form Window Project Window Sizing Handles Toolbox Toolbar Form Size
7
Visual Basic Menu Bar
8
Visual Basic Tool Box
9
Project Explorer Window View code View Object Change Folders Used to select the code or object or to change folders.
10
The Properties Window Used to change the properties of controls at design time. Object Box Properties List Tabs Window Name Scrollable list of properties Description Pane
11
Important Properties**** Property - attribute of a control object that can be set by the designer **** Name property: identifies the control –Should start with three letter prefix lbl for label txt for text box frm for form –Can include letters, numbers, and underscore
12
Other Properties **** Caption property for labels--allows you to change the text displayed on a command button **** Can code the text that appears in a command button**** Private Sub Command1_Click() Command1.CAPTION=“Click me” End Sub Stretch Property - enlarges the image control and the image simultaneously if set to True ****
13
Adding a Control Control - an object with built-in properties that can be placed on a VB form **** Double-click to add control to center of form –Can be moved around from there –Use sizing handles to change size Single Click and draw on form
14
Controls to Add to Form Label control: provides description of other controls and displays read-only text **** Image control: holds a graphic image**** –Stretch property should be set to True**** –Picture property is set to graphic file Command button control: can be clicked to respond to user events **** – Uses Caption property
15
Adding Code to Project Code goes in Code Window in event procedure Event procedure begins with “Private Sub…” and ends with “End Sub” Use Msgbox command to display dialog box with message Msgbox “Welcome to Vintage Videos”
16
Design Time and Run Time You are in “Design Time” when you are creating and modifying the project and adding code **** You are in “Run Time” when you click the VCR Run icon and the VB program is being executed **** You can stop the project and exit Run time by clicking the VCR Stop Icon. You can go to “Break Mode” by clicking the VCR Pause Icon.
17
The Toolbar and Menu System The VB menu system provides access to all commands. The Toolbar uses icons for more commonly used menu commands.
18
Files in Visual Basic All projects in VB have a.vbp (project) file and at least one.frm (form file) file. Always save.frm files first and then save project files. Use File|Save or File|Save as… commands for this purpose or click Disk icon on toolbar. Projects with graphics also have.frx (binary form) files. They are saved automatically. Module files have a.bas extension and are pure code files.
19
Flowcharting Symbols Flowchart – diagram that shows the ”flow” of program events through time Specific shapes represent different processes performed by the computer Flowline – lines with arrows on the end that connect flowchart symbols
20
Flowcharting Symbols Terminator – oval that show starting and ending points of the program StartStop
21
Flowcharting Symbols Data Input or Output - - parallelogram show what user inputs and what the computer outputs Processing - -rectangle operation performed by the computer, such as variable assignment or mathematical calculation Pay=Hrs* Rate
22
Flowcharting Symbols Decision – diamond indicates a decision structure. Always has two flowlines out. Flowline out is labeled the ”Yes”: branch” and the flowline in is labeled “No”. NO Yes >40 hrs
23
Flowcharting Symbols Predefined process - rectangle with two parallel lines on the right and left. One statement denotes a group of previously defined statement. For instance, calling a subroutine. Call ValidateInfo
24
Flowcharting Symbols Connector - small circle – prevent crossing flowlines making the flowchart easier to read. Come in pairs Endif
25
Flowcharting Symbols Off page connector – looks like “home plate” in baseball – indicates the continuation of a flowchart to another page and come in pairs
26
Visual Basic Help There are three types of Help: –Help menu option –context-sensitive help –and Auto Help In VB 6, Help uses the familiar Internet Explorer browser interface for the first two types of help. You can seek help by selecting Contents, Index, or Search from the Help menu item
27
Context-Sensitive and Auto Help With context-sensitive help, pressing the F1 key provides help on whatever item the cursor is located. With Auto Help, VB tries to help you with a code statement by providing: –A list of items to complete the statement –Info on the statement you have started –Tips on the type of data you are working with
28
Accessing MSDN Help Since the Help feature is disabled in the Working Edition Model of VB 6.0 you can use the Internet to access Microsoft Developers Network (MSDN) The web site is: http://msdn.microsoft.com/library/default.asp Expand Visual Tools and Languages Expand Visual Studio 6.0 Select Visual Basic 6.0
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.