visual basic v6 introduction

26
Introduction to Visual Basic Visual Beginners All- Purpose Symbolic Instruction Code

Upload: bloodyedge03

Post on 19-Jan-2015

2.056 views

Category:

Documents


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: visual basic v6 introduction

Introduction to Visual Basic

Visual Beginners All-Purpose Symbolic Instruction Code

Page 2: visual basic v6 introduction

Visual Basic

• is a tool that allows you to develop Windows (Graphic User Interface - GUI) applications.

• is event-driven, meaning code remains idle until called upon to respond to some event.

Page 3: visual basic v6 introduction

Steps in Developing Application

1. Draw the user interface2. Assign properties to controls3. Attach code to controls

Page 4: visual basic v6 introduction

Draw the User Interface

Visual Basic operates in three modes.• Design mode - used to build application• Run mode - used to run the application• Break mode - application halted and debugger

is available

Page 5: visual basic v6 introduction

Getting Started

Page 6: visual basic v6 introduction

7 Windows

1. Main Window2. Form Window3. Toolbox4. Properties Window 5. Form Layout Window6. Project Window7. Code Editor Window

Page 7: visual basic v6 introduction

Main Window

• consists of the title bar, menu bar, and toolbar.

Page 8: visual basic v6 introduction

Form Window

• is central to developing Visual Basic applications. It is where you draw your application.

Page 9: visual basic v6 introduction

Toolbox• is the

selection menu for controls used in your application.

Page 10: visual basic v6 introduction

Properties Window

• is used to establish initial property values for objects.

Page 11: visual basic v6 introduction

Form Layout Window

• shows where (upon program execution) your form will be displayed relative to your monitor’s screen.

Page 12: visual basic v6 introduction

Project Window

• displays a list of all forms and modules making up your application.

Page 13: visual basic v6 introduction

Code Editor Window

• Contains the actual Basic coding.

Page 14: visual basic v6 introduction

Assign Properties to Controls

• Naming Convention of ControlsObject Prefix Example

Form frm frmHello

Command Button cmd, btn cmdExit, btnStart

Label lbl lblStart, lblEnd

TextBox txt txtTime, txtName

Menu mnu mnuExit, mnuSave

Check box chk chkChoice

Page 15: visual basic v6 introduction

Attach Code to Controls

• Code in a Visual Basic application is divided into smaller blocks called procedures.

• Event procedure syntax:

object name_event ()Ex. Command1_Click ()

Page 16: visual basic v6 introduction

Private Sub object name_event ()

End Sub _______________________________________

Private Sub Command1_Click ()

End Sub

Page 17: visual basic v6 introduction

Private Sub Command1_Click ()

object name.property = valueEnd Sub_______________________________________Private Sub Command1_Click ()

Text1.Text = "Hello, world!"End Sub

Page 18: visual basic v6 introduction

Variables

Rules used in naming variables:• No more than 40 characters.• They may include letters, numbers, and

underscore (_).• The first character must be a letter.• You cannot use a reserved word.

Page 19: visual basic v6 introduction

Data Types

Page 20: visual basic v6 introduction

Variable Declaration1. Default (variant)2. Implicit

Amount% = 3003. Explicit

four levels of scope• Procedure level• Procedure level, static• Form and module level• Global level

Page 21: visual basic v6 introduction

• Procedure levelDim Variable name as Data type

Ex. Dim Myint as integer• Procedure level, static

Static Variable name as Data typeEx. Dim Myint as integer

Page 22: visual basic v6 introduction

• Form and module levelDim Variable name as Data type

Ex. Dim Myint as integer• Global level

Global Variable name as Data typeEx. Dim Myint as integer

Page 23: visual basic v6 introduction
Page 24: visual basic v6 introduction

• Procedure Routine1 has access to __, __, and __(…..)

• Procedure Routine2 has access to __, __, and __(…..)

• Procedure Routine3 has access to __, __, and __(…..)

Page 25: visual basic v6 introduction

• Procedure Routine1 has access to X, Y, and A (loses value upon termination)

• Procedure Routine2 has access to X, Y, and B (retains value)

• Procedure Routine3 has access to X, Z, and C (loses value)

Page 26: visual basic v6 introduction