Title: Introduction to Computing
1Introduction to Computing
2Lecture 13
3Scroll Bar (Horizontal and Vertical)
-
- Properties
- Name
- Max
- Min
- Value
- Large Change
- Small Change
- etc.
4Scroll Bar (Horizontal and Vertical)
- (Contd.)
-
- Events
- Change
- Scroll
- etc.
5Timer, Line, Shape
- Read about them in the book
6The Format Menu
- Try out various formatting commands in
- the Format Menu
7States of Visual Basic
- Three states of Visual Basic
- Design State
- Execution State
- and
- Break State
8States of Visual Basic (Contd.)
- Break State Execution interrupted temporarily
- Press F5 to resume or choose Run gt Continue
- Immediate Window is activated
- Can edit code, Issue commands in the immediate
window, Cannot edit the user-interface
9The Immediate Window
- Useful for debugging
- Tryout commands in the break state like
- Print Label1.Caption
- Print (1234)/5
- Label1.Caption Hello World
- Picture1.Print Hello
10What is Focus ?
11Focus
- The ability of a control to receive user input
- Related Events
- GotFocus
- LostFocus
- Related Properties
- TabIndex
- TabStop
12Focus (Contd.)
- Related Methods
- SetFocus
- The statement
- Text1.SetFocus shift focus to Text1 Text Box
- gt Access Key can also be used to get focus
13VB Objects and Properties
- Names
- Appearance (Flat look/3-D look etc.)
- BackColor
- ForeColor
- Font
- Caption
- Text
- Width, Height
- Left, Top
14VB Objects and Properties (Contd.)
- Enabled True/False
- False
- Cannot accept user input
- Cannot get focus
- Visible True/False
- False Control is invisible
- etc.
15VB Objects and Methods
- 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
16VB Objects and Methods (Contd.)
- Move For moving and resizing objects
- e.g
-
- Control.Move left, top, width, height
- gtmore on Methods in book or use help
17VB Objects and Events
- Event is a controls 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 -
18VB Objects and Events (Contd.)
- Click, DblClick
- events related to pressing left mouse button
- KeyPress
- Events related to pressing a key
-
19VB Objects and Events (Contd.)
- More Events
- related to Mouse
- MouseDown, MouseUp, MouseMove etc.
- related to keyboard
- KeyDown, Keyup etc.
- more on Events in book or use help
-
20VB Objects and Events (Contd.)
- 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
21Event-Driven Programming
- Application does not determine the flow
- Events caused by the user determine the flow
22Object Oriented Programming?
23Built-in Functions
- Take one or more input values
- Return an output value
- Already seen
- Val(..), Str(..), Asc(..), Chr(..)
24Built-in Numeric Functions
- Sqr calculates square-root and returns the value
as double data type - e.g
- Sqr(9) is 3
- Sqr(0) is 0
- Sqr(2) is 1.414214
- Sqr(3024) is 8
25Built-in Numeric Functions
- Int Greatest integer less than and equal to a
number - e.g
- Int(2.7) is 2
- Int(3) is 3
- Int(-2.7) is -3
26Built-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
27Remember Assignment 4
- It has been posted See the Website
28Refer to
- Schneider Section 3.6
- Brown Chapter 3(p76-104 p115-p127)