visual basic

18
VISUAL BASIC Lecture #4 WORKING WITH FRAMES By Shahid Naseem (Lecturer)

Upload: vartan

Post on 15-Feb-2016

29 views

Category:

Documents


0 download

DESCRIPTION

VISUAL BASIC. Lecture #4 WORKING WITH FRAMES. By Shahid Naseem (Lecturer). LECTURE OUTLINES. LECTURE OUTLINES. Event of command buttons Uses of Command buttons List box controls Programs. BOOKS AVAILABLE IN MARKET. C Programming using Turbo C++ Schaum Series - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: VISUAL BASIC

VISUAL BASICLecture #4

WORKING WITH FRAMES

ByShahid Naseem

(Lecturer)

Page 2: VISUAL BASIC

LECTURE OUTLINES

Page 3: VISUAL BASIC

LECTURE OUTLINESEvent of command buttonsUses of Command buttonsList box controlsPrograms

Introduction of Visual Basic (Civil Engineering Department)

Page 4: VISUAL BASIC

BOOKS AVAILABLE IN MARKETC Programming using Turbo C++

Schaum Series

Introduction to Computer 7th edition Peter Norton

How to Programming with C++ 8th Edition Deitel & Deitel

Visual Basic 2005 Evangelos Petroutsos

Introduction of Visual Basic (Civil Engineering Department)

Page 5: VISUAL BASIC

DEBUGGINGThe errors in the program are called bugs. The process

to detect and to remove errors in the program is called debugging. Syntax errors Run time errors Logical errors

Syntax errorsThe rules for writing the computer programs in a

programming language is known as syntax of the language.

The syntax errors occurred when the syntax of the programming language are not followed.

The syntax errors are easy to locate and remove.

Introduction of Visual Basic (Civil Engineering Department)

Page 6: VISUAL BASIC

DEBUGGINGe.g.

Private sub command1 _click (()For 1,10End sub

MessageCompile errorExpected: to

Run time errorsThe errors that are occur during the execution of

program are called the run time errors. If input data given to the program is not correct. If hardware problem occurs such as hard disk error.

Introduction of Visual Basic (Civil Engineering Department)

Page 7: VISUAL BASIC

WORKING WITH FORMEvent of Form

Load: when form is loaded in the memory

Unload: when form is unloaded from the memory.

Activate: When form is on the screen Deactivate: When form is Off from the screen Resize: When form is resized.

Methods of form: The show method The hide method The print form method The unload statement.

Introduction of Visual Basic (Civil Engineering Department)

Page 8: VISUAL BASIC

PROGRAM#4Develop an application program having form

with no GUI control. It should perform the following actions when user interacts with form. The form appears maximized when program is run. Set background color appears as “red” when mouse

is single clicked on the form and background color is changed to “green” when mouse is double clicked on the form.

Form1 Caption Form testing program

Window state 2-maximized

Introduction of Visual Basic (Civil Engineering Department)

Page 9: VISUAL BASIC

PROGRAM#4

Private Sub Form_Click()Form1.BackColor = vbRedEnd Sub

Introduction of Visual Basic (Civil Engineering Department)

Page 10: VISUAL BASIC

PROGRAM#4

Private Sub Form_DblClick()Form1.BackColor = vbGreenEnd Sub

Introduction of Visual Basic (Civil Engineering Department)

Page 11: VISUAL BASIC

EVENT OF COMMAND BUTTONSClick: The click event is the primary and commonly used event of

command button. It is triggered when:

Command button is singled clicked. Command button has the focus and the enter key or

spacebar key is pressed. Command button access key is pressed.

Dbl Click: This event of command button is triggered when mouse is double

clicked on button.Mouse Click: This event of command button is triggered when mouse pointer is

moved over the button.Got Focus: This event of command button is triggered when it gets focus.Lost Focus: This event of command button is triggered when it loses focus.

Introduction of Visual Basic (Civil Engineering Department)

Page 12: VISUAL BASIC

PROGRAM#5

Introduction of Visual Basic (Civil Engineering Department)

Page 13: VISUAL BASIC

PROGRAM#5Form1 Caption Command Button

ApplicationCommand1 Caption First Button

Style GraphicalCommand2 Caption Second Button

Style GraphicalCommand3 Caption Third Button

Style Graphical

Private Sub Command1_Click()Form1.BackColor = vbRedCommand1.BackColor = vbGreenCommand2.BackColor = vbYellowCommand3.BackColor = vbBlueEnd Sub

Introduction of Visual Basic (Civil Engineering Department)

Page 14: VISUAL BASIC

PROGRAM#6

Introduction of Visual Basic (Civil Engineering Department)

Develop an application program to perform simple arithmetic operations by two numbers.

Form1 Caption Arithmetic Operations

Label1 Caption Enter First Number

Label2 Caption Enter Second Number

Label3 blankText1 blankText2 blankCommand1 Caption Operation 

Page 15: VISUAL BASIC

PROGRAM#6

Introduction of Visual Basic (Civil Engineering Department)

Private Sub Command1_Click()Label3.Caption = Val(Text1.Text) + Val(Text2.Text)End Sub

  

Page 16: VISUAL BASIC

LIST BOX CONTROL

Introduction of Visual Basic (Civil Engineering Department)

The list box control is used to display a long list of items.Properties Events

ListList countList Index ClickMouse Select Dbl ClickStyleSelectedSelect CountSortedIndexText

Page 17: VISUAL BASIC

PROGRAM#7

Introduction of Visual Basic (Civil Engineering Department)

Develop an application program to add and delete items to and from the list at runtime asType the text box and click add button to add

the item to list box.Select the item from list and click delete button

to delete the selected item.

Page 18: VISUAL BASIC

PROGRAM#7

Introduction of Visual Basic (Civil Engineering Department)

Private Sub Command1_Click()List1.AddItem Text1.TextText1.Text = ""End Sub Private Sub Command2_Click()List1.RemoveItem (List1.ListIndex) End Sub