Download presentation
Presentation is loading. Please wait.
1
Introduction to Visual Basic Programming
2
Lecture Outline History What is Visual Basic First Look at the VB 6.0 Environment Some VB Terminology Our first VB Program
3
History
4
BASIC BASIC (Beginner's All-purpose Symbolic Instruction Code) Designed in 1964, by Kemeny and Kurtz at Dartmouth Goal was to provide access for non-science students to computers. Back then all use of computers required writing custom software – But only Computer Scientists/Mathematicians did this Language became widespread on microcomputers in the late 1970s and home computers in the 1980s.
5
A Simple BASIC Program
6
MS DOS Command Line
7
MS-DOS Shell
8
Visual Programming (MS Windows 3.1)
9
Visual Programming Today (MS Vista)
10
What is Visual Basic?
11
What is Visual Basic? Visual Basic (VB) is a Microsoft Windows programming language (SOFTWARE development language) Visual Basic is derived from the BASIC (Beginners All-purpose Symbolic Instruction Code) programming language BASIC was developed in the mid-1960s The widespread use of BASIC led to many enhancements to the language In the late 1980s and early 1990s, with the development of the Microsoft Windows (Graphic User Interface) GUI, the natural evolution of BASIC was Visual Basic (created by Microsoft in 1991)
12
VB greatly simplifies the development of Microsoft Windows-based Applications Between 1991 and 1998 6 versions of VB were released, with Visual Basic 6 appearing in September 1998. Microsoft provides several versions of VB, namely the Learning Edition, the Professional Edition and the Enterprise Edition VB programs are created in an Integrated Development Environment (IDE). The IDE allows a programmer to create, run and debug VB programs conveniently. The process of rapidly creating an application is typically referred to as Rapid Application Development (RAD). VB is the most widely used RAD language.
13
The Visual Basic Environment Visual Studio
14
The Visual Basic Environment In using VB you will learn to write computer programs that run in the Microsoft Windows environment Projects will look and act like standard Windows programs VB provides the tools you need to create windows with familiar elements like: Menus, Text Boxes, Command Buttons, Option Buttons, Check Boxes, List Boxes, and Scroll Bars
15
Microsoft Windows uses a Graphic User Interface (GUI) The Windows GUI defines how the various elements look and function Within VB there is a Toolbox of these elements In VB you will create new Windows called Forms Using the toolbox to add the various elements, called Controls, to the form VB programming is known as Event-Driven Programming
16
The Initial Visual Basic Screen Toolbox Project Explorer window Properties window Form Menu bar Description pane Form Layout window Toolbar Project Container window
17
Some VB Terminology Objects, Properties and Methods
18
In VB you work with Objects, which have Properties and Methods Objects: Think of an Object as a thing, or a noun Examples of Objects are Forms and Controls Forms are the Windows and Dialog Boxes that you place on the screen Controls are the elements you place inside a form, such as Text Boxes, Command Buttons, and List Boxes
19
Properties: Think of Properties as adjectives that describe objects Properties tell something about an Object, such as the name, colour, size, location, and how it will behave When you refer to a Property [1] Name the Object [2] Name the Property (Example: Form1.Caption) The Caption Property of the Object (Form) called Form1
20
Methods: Methods are the verbs of Object-Oriented Programming Methods are Actions associated with Objects Example of Methods include Move, Print, Resize, and Clear Refer to Methods as: Object.Method (Example: Form1.Print) Sends output (Prints) to the Object (Form) called Form1 (Question: What does this Method refer to?) Printer.Print
21
Steps to Create a Visual Basic Program 1. Create the interface by placing controls on the form 2. Set properties for the controls and the form 3. Write code for event procedures associated with the controls and the form
22
Placing a Text Box on a Form Double-click on the text box icon in the toolbox to add a text box to your form Activate the properties window (Press F4) Set values of properties for text box
23
Placing a Text Box on a Form Text box
24
Our First VB Program “Hello World”
25
Private Sub cmdPush_Click ‘Display the ‘Hello World’ Message lblMessage.Caption = “Hello World” End Sub *********************************************** Private Sub cmdExit_Click ‘Exit the project End End Sub Comment Assignment
26
Naming Objects:
27
Visual Basic Events Code is a set of statements that instruct the computer to carry out a task. Code can be associated with events When an event occurs, the code associated with that event (called an Event Procedure) is executed.
28
Creating An Event Procedure Double-click on an object to open a Code window. (The empty default event procedure will appear. Click on the Procedure box if you want to display a different event procedure.) Write the code for that event procedure.
29
Example of An Event Procedure Private Sub objectName_event ( ) statements End Sub Private Sub txtOne_GotFocus( ) txtOne.Font.Size = 12 txtOne.Font.Bold = False End Sub
30
More Examples Private Sub cmdButton_Click( ) txtBox.ForeColor = vbRed txtBox.Font.Size = 24 txtBox.Text = “Hello” End Sub
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.