Download presentation
Presentation is loading. Please wait.
1
Introduction to Computing Dr. Nadeem A Khan
2
Lecture 13
3
► Properties Name Max Min Value Large Change Small Change etc. Scroll Bar (Horizontal and Vertical)
4
► Events Change Scroll etc. Scroll Bar (Horizontal and Vertical) - (Contd.)
5
► Read about them in the book Timer, Line, Shape
6
► Try out various formatting commands in the Format Menu the Format Menu The Format Menu
7
States of Visual Basic Three states of Visual Basic: ► Design State ► Execution State and and ► Break State
8
States of Visual Basic (Contd.) ► Break State: Execution interrupted temporarily Press F5 to resume or choose Run > Continue Immediate Window is activated Can edit code, Issue commands in the immediate window, Cannot edit the user-interface
9
► Useful for debugging ► Tryout commands in the break state like: Print Label1.Caption Print (1+2+3+4)/5 Label1.Caption= “Hello World” Picture1.Print “Hello” The Immediate Window
10
What is Focus ?
11
► The ability of a control to receive user input ► Related Events GotFocus LostFocus ► Related Properties TabIndex TabStop Focus
12
► Related Methods SetFocus ► The statement Text1.SetFocus‘shift focus to Text1 Text Box => Access Key can also be used to get focus Focus (Contd.)
13
► Names ► Appearance: (Flat look/3-D look etc.) ► BackColor ► ForeColor ► Font ► Caption ► Text ► Width, Height ► Left, Top VB Objects and Properties
14
► Enabled: True/False False: ► Cannot accept user input ► Cannot get focus ► Visible: True/False False: Control is invisible etc. VB Objects and Properties (Contd.)
15
Methods are actions that objects can carry out ► Print: e.g: Picture1.Print Printer.Print Form1.Print ► Cls: Contents are discarded e.g: Picture1.Cls‘ to clear the text in the picture box Form1.Cls ‘ to clear the text on the form VB Objects and Methods
16
► Move: For moving and resizing objects e.g: Control.Move left, top, width, height =>more on Methods in book or use help VB Objects and Methods (Contd.)
17
Event is a control’s response to an external action ► Change: e.g: VScroll1_Change (Value property of the Scroll Bar is changed) Text1_Change (each time a new character is typed in or deleted in the Text Box) Check1_Change (each time the user changes the status of the Check Box by clicking it VB Objects and Events
18
► Click, DblClick: events related to pressing left mouse button ► KeyPress: Events related to pressing a key VB Objects and Events (Contd.)
19
► More Events related to Mouse ► MouseDown, MouseUp, MouseMove etc. related to keyboard ► KeyDown, Keyup etc. more on Events in book or use help VB Objects and Events (Contd.)
20
► Event procedures implement the user-response Sub Label1_DblClick( ) Rem An event procedure with no arguments …. End Sub Sub Text1_KeyPress(KeyAscii As Integer) Rem An event procedure with an argument KeyAscii ….. End Sub VB Objects and Events (Contd.)
21
Application does not determine the flow; Events caused by the user determine the flow Event-Driven Programming
22
Object Oriented Programming?
23
Built-in Functions ► Take one or more input values ► Return an output value ► Already seen: Val(..), Str$(..), Asc(..), Chr(..)
24
Built-in Numeric Functions ► Sqr: calculates square-root and returns the value as double data type e.g: e.g: Sqr(9) is 3 Sqr(0) is 0 Sqr(2) is 1.414214 Sqr(30*2+4) is 8
25
Built-in Numeric Functions ► Int: Greatest integer less than and equal to a number e.g: e.g: Int(2.7) is 2 Int(3) is 3 Int(-2.7) is -3
26
Built-in String Functions ► Left$, Mid$, Right$, UCase$, Trim$ Left$(“fanatic”, 3) is “fan”Right$(“fanatic”, 3) is “tic” Left$(“12/15/93”,2) is “12”Right$(“12/15/93”, 2) is “93” Mid$(“fanatic”, 5,1) is “t”Mid$(“12/15/93”,4, 2) is “15” Ucase(“Disk”) is “DISK”Ucase(“12two”) is “12TWO” Trim$(“ 1 2 ”) is “1 2”Trim$(“-12 ”) is “-12”
27
Remember Assignment 4 ► It has been posted: See the Website
28
Refer to: ► Schneider: Section 3.6 ► Brown: Chapter 3(p76-104; p115-p127)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.