0% found this document useful (0 votes)
64 views10 pages

VB Controls and Events: Introduc) On

This document provides an introduction to visual basic controls and events. It discusses why visual basic is used, how to create visual basic programs using controls, events, and procedures. It also covers flowcharting, pseudocode, the visual basic interface, and creating a new visual basic project. Homework assignments involve installing visual basic and learning to create programs using its objects and properties.

Uploaded by

I-Vinay Chhabra
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views10 pages

VB Controls and Events: Introduc) On

This document provides an introduction to visual basic controls and events. It discusses why visual basic is used, how to create visual basic programs using controls, events, and procedures. It also covers flowcharting, pseudocode, the visual basic interface, and creating a new visual basic project. Homework assignments involve installing visual basic and learning to create programs using its objects and properties.

Uploaded by

I-Vinay Chhabra
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

8/25/10

CE 311 K Introduc/on to Computer Methods

VB Controls and Events


Daene C. McKinney

Introduc)on
Program Planning and Flowcharts Visual Basic Visual basic Interface VB Controls CreaGng a Project

8/25/10

Why Visual Basic?


#1 Reasons
Graphical User Interface (GUI) - easily constructed More fun for students than other languages!

The other reasons

General purpose, machine-independent language Powerful and exible language Popular (used by many programmers, its been around since . well MS DOS. Yeah, Bill Gates wrote it!) Portable (works on all PCs) Small language (few components) Modular (easily maintainable)

VB Programs
Developing a VB Program
Design the GUI (bu^ons, text boxes, etc.) Determine the events that the controls (bu^ons, etc.) will recognize Write the procedures for those events
Whats an EVENT? CLICK!

Running a VB Program

Whats a PROCEDURE?

VB monitors the controls in the window for events When it detects an event, execute procedure for that event Return to monitoring

RUN? Is this a race?

Sounds easy, but it can be frustraGng!

8/25/10

Flowchar)ng
Flowchart Flowchart Symbols
Start/Stop
Start

This can save your &^%$ when you lose track of what youre doing!

Graphic representaGon of the sequence of steps in a process

Line
Decision

no yes Process

Input/Output Processing Decision

Stop

Example: Stamp Problem


Flowchart
Start Read sheets Set stamps = sheets/5 Round stamps up To next whole # Display stamps

Pseudocode
Program Purpose: Determine the proper number of stamps for a leCer

Input Processing Processing Output

Read sheets Set the number of stamps to sheets/5 Round the number of stamps up to the next whole number Display the number of stamps

End

8/25/10

Decisions
Flowchart Pseudocode

No

Is condiGon True?

Yes

If condiGon is true, then


Process step(s) 1

Process Step(s) 2

Process Step(s) 1

Else
Process step(s) 2

End if

Average Grade Problem


Flowchart
Start Sum=0 Count = 0

Pseudocode
BEGIN Average Grade sum=0 count = 0 Input Grade LOOP WHILE grade > 0 sum = sum + grade count = count +1 END LOOP
average = sum/count

Sum = Sum + Grade Count = Count + 1 Yes

Input Grade

More grades? No Average = Sum/Count

END Average Grade

Note: We can translate this pseudocode into any programming language.

Note: This program will crash if there are no grades input, i.e., count = 0

Stop

8/25/10

VB Interface

New Project Bu^on

Crea)ng a New Project in VB

Windows Forms ApplicaGon

8/25/10

VB Form Designer Window


Project Controls Form

To acGvate controls, select Toolbox and press Push-Pin

VB Form Designer Window


Project Controls Form

8/25/10

A LiCle Visual Basic


Controls
Picture boxes (pic) Text boxes (txt) Bu^ons (cmd)

Visual Basic Objects


Useful Objects
List Boxes Text Boxes Picture Boxes Labels Bu^ons

Useful Object Proper)es


Name CapGon Border style Visible Back Color Alignment Font

8/25/10

Visual Basic Events


When a VB program runs
A Form and some Controls appear on the screen

Nothing happens unGl user takes an acGon


Event

Most Events are associated with Controls


Objects

Programmer writes Code to respond to events


Procedures

Boxes and BuCons


VB: Object-oriented language
Objects: Controls
Text boxes, Picture boxes, Bu^ons, etc

Procedures: tasks that objects perform


Dot separates object name from method (TextBox1.TEXT) Method: Assign text to a text box

BuCon BuCon code

8/25/10

Crea)ng a Visual Basic Program


1. 2. 3. 4. 5. 6. IdenGfy Problem Design Algorithm Design GUI (interface) Create Objects Set ProperGes Write Procedures for Events (bu^on clicks, etc.) 7. Test Your Program
IdenGfy Problem Design Algorithm

Design GUI

Create Objects

Set ProperGes of Objects

Write Procedures for Events

Test

Homeworks
Install Do
VB-2008
from the MS website or the CD at back of the book

Learn Make Use

Homework problems in VB How to create VB projects and solve problems Screenshots and paste them into Word docs Your computer

8/25/10

Summary
Program Planning and Flowcharts Visual Basic Visual basic Interface VB Controls CreaGng a Project

10

You might also like