• No results found

VISUAL BASIC Controls. Version 1 Trg. Div., NIC HQRs

N/A
N/A
Protected

Academic year: 2021

Share "VISUAL BASIC Controls. Version 1 Trg. Div., NIC HQRs"

Copied!
34
0
0

Loading.... (view fulltext now)

Full text

(1)

VISUAL BASIC

Controls

(2)

These are the objects which can be

pasted onto a form which display text,

through picture boxes for graphic

images, to buttons, check boxes, lists

and other menus. Each control can have

code attached to it.

(3)

ToolBox

ToolBox

?

Tool Box contains the standard controls.

?

You can add more controls by from

components

?

You can create your own controls ActiveX

controls customised to specific purposes

(4)

Picture Box

Text box

Command Button

Option Button

List box

Vertical scroll bar

Drive list

File list box

Line object

Data control

Pointer

Label control

Frame control

Check box

Combo box

Horizontal scroll bar

Timer Control

Directory list box

Shape Object

Image object

(5)

Visual Basic Controls

Visual Basic Controls

Some of the common terminology associated with

control

?

Control as a object

?

Property

?

Method

?

Event

?

Procedure

?

Program Statement

?

Variable

(6)

Version 1

Property

Property

?

With each object , various properties are

associated which describe its characteristics. The

properties can be set at design time by using

property window or at run time through program

statements

Eg: Command1.Caption = “ Hello”

Few common properties are:

Name, Caption, Appearance, Enable (True / False),

Visible ( True / false) etc.

(7)

Program Statement

Program Statement

It is a keyword in the code that does the work of a

program

Eg: Unload formissue

Call DISABLE ( Call procedure Disable)

Form2.Show

Setdb = OpenDatabase(C:inventory.mdb)

Data1.UpdateRecord etc.

(8)

Variable

Variable

?

It is a special container that holds data

temporarily in a program

?

Numbers, Charatcter strings, property

values etc can be stored in variables

Eg : Dim db As Database

Dim strdiv As String

Dim rs As Recordset

(9)

Method

Method

?

It is a special statement that performs an

action or a service for a particular object in

a program

Syntax : Object.Method Value

Eg : List1.AddItem “Printer”

ShowOpen

SowPrint etc.

(10)

Form Events

Form Events

?

Whenever an event is triggered ( click, drag,

resize, double click, key press etc.) a message is

generated that describes your action.This message

is sent to appropriate control, which in turn

generates appropriate action based on pre-defined

method.

?

The event message can be customised the way

(11)

Event Procedure

Event Procedure

?

It is a block of code that is executed when

an object is manipulated in a program.

Eg: When an event takes place, block of

program code associated with it gets

executed.

Few common events are :

Click, Dbclick, MouseDown, MouseUp,

MouseMove etc.

(12)

Form Methods

Form Methods

?

It is a command that allows you to tell an

object what to do

eg: Show

hide, Unload, Print

An example of programming construct:

If Lable1.Caption = “xxx” Then hide form1

Object Property Assigned VB

method Object

name name Operator Function

(13)

Nomenclature convention of

Nomenclature convention of

the objects

the objects

For forms (

three nomenclatures are associated with it)

1. Name of the object form

2. Name of the caption of the form

3 Form file name for saving it as a part of project

To avoid any confusion later, one should follow a convention of

nomenclature, and should strictly follow throughout the project

It is suggested to follow a convention:illustrated as follows

1 name the form object as -> frmSample

2. Name of the caption as -> Sample

3. Name of the file for saving it: -> Sample

(14)

Nomenclature convention of

Nomenclature convention of

the objects

the objects

For other objects

It is suggested to follow a convention:illustrated as follows

1 Name of an object frmSample, txtName, mnuMain, cmdOK,

cmdAddItem , datCourses etc.

2. Caption of the object The way, you want it to appear on the

screen etc.

(15)

Pointer

The pointer is used for

selecting objects which is

to placed on the form.

(16)

Picture box

A Picture box holds pictures created with the

paintbrush or similar art packages. These must be

in acceptable format like .BMP, .WMF, .ICO etc.

.BMP Bitmap

.WMF Windows MetaFile

.ICO Icons

.GIF Graphic Interchange Format

.JPG Joint Photographic Expert Group

. DIB Device Independent Bitmap

(17)

Image control is designed

specifically for displaying images

and not for creating new images or

manipulating

(18)

Labels and Text Boxes

Labels and Text boxes both holds

text, but only Text Box is capable of

receiving input from the user.

Command Button

Command buttons are one method of selection.

They are typically used Where there are limited

number of options - the choice may be be

OK

(19)

1

. Click the textbox control in the toolbox.

2. Move the mouse pointer to the form. Draw the Textbox of your need.

3. Click the command button control to the form

4. Draw the command button of any size.

5. Use the Properties set window & set the

Properties as

Control

Property

Setting

Text1 Text (empty)

Command1 Caption “OK”

6. Double click the OK command button. Type the

following

Text1.Text = “ Starting of Visual Basic”

7. Now Run the program

(20)

Frame Control

A Frame simply holds things together. If

you place a set of controls with in a

frame, they are all moved together as the

frame is moved.

Note:- that once a control has been

placed in a frame, it cannot be

moved out onto the form, and vice

versa.

(21)

Check Boxes

Check boxes act as toggle

switches, turning options

on or off.

(22)

Option buttons

Option buttons are normally

used to select one from a set

of mutually exclusive

options. At any one time

there can be only one set on

a form, unless they are

(23)

List box

List boxes display list of items,

so that user can see what is

available and select one. If the

list is too long to fit in box,

vertical scroll bar will be added

at run time. Items can only be

added to the list at the run- time ,

not at design time

.

(24)

1. Drag the List Box on the Form

2. Double Click the List Box and type the following

Private Sub Form_Load()

List1.AddItem "White"

List1.AddItem "Black"

List1.AddItem "Yellow"

List1.AddItem "Green"

List1.AddItem "Red

"

End Sub

3. Run

(25)

Combo box

A Combo box combine a

drop-down list with a slot in which

user can enter their own data

when the program is running

(26)

1. Drag the List Box on the Form

2. Double Click the List Box and type the

following

Private Sub Form_Load()

Combo1.AddItem "one"

Combo1.AddItem "two"

Combo1.AddItem "three"

Combo1.AddItem "four"

Combo1.AddItem "five"

Combo1.AddItem "six”

End Sub

3. Run

(27)

Horizontal and Vertical scroll bars

The Horizontal and Vertical scroll

bars are used on forms to give a

very flexible means of setting

values. When the Program is

running, the position of the slider

determines the value returned by

the scroll bar.

(28)

Timer

The Timer is unusual in that it is to be fixed size

and is invisible once the program is running. Its

purpose is to control actions the must take place

at or after set intervals.

(29)

Private Sub Command1_Click()

If Text1.Text = "secret" Then

Timer1.Enabled = False

MsgBox ("Welcome To the System")

Else

MsgBox ("Sorry, Friend, I don't know you.")

End If

End Sub

Private Sub Timer1_Timer()

MsgBox ("Sorry , Your time is up.")

End

(30)

Drive List box , Directory List box

and File List box

The Drive List box,Directory List box and File List box

can be used together to give the standard Windows

file management facilities. When the program runs

they will initially display the current drive and

directory. These can be changed by clicking and

highlighting in the usual way. Three boxes together

can produce a highly efficient file selection routine.

(31)

USE OF DRIVELISTBOX, DIRECTORY LISTBOX ,

FILE LISTBOX & IMAGE CONTROLS

1. Click theDriveListBox in the toolbox.

2. Move the mouse pointer to the upper-left corner of the form and then draw a drivelistbox.

3. Similarly draw the Directorylistbox and filelistbox.

4. Add the image box control to the right side of your form. 5. Double click the drivelistbox and type the following

Dire1.Path = Drive1.Drive Close the Code window

6. Double click the directorylistbox and type the following File1.Path = Dir1.Path

Close the Code window

7. Double click the Filelistbox and add the following code to the File1_Click event procdure.

(32)

The Shapes (either a circle, oval, square or

rectangle)

(33)

Data Control

The Data control allows you to read

records in from a database

(34)

OLE

OLE stands for Object Linking

and Embedding. This control

allows you to make a two way

link with an object in another

Windows application.

References

Related documents

PARTS & STRUCTURAL OVERVIEW Left Arm Arms Feet Legs Brace Control Box Handset Rack Handset Control Box Rack Crossbeam Right Arm Brace.. Control

Scroll down to the “UTM Profile” feature and check the box to enable the Application Patrol, click on the dropdown and select the App Patrol profile to apply to this policy

- Click the windows icon in lower left of screen and type UAC in the search programs and file box (the user account control settings box will appear)8. - Slide the notification

information is known for the drinking-water system, however, it would have to be included in Financial Plans. Huron East Council acknowledges the provisions of Subsection 3.2

that needs to be activated (see table below). The red LED will flash once to confirm that the limit switch function is activated. Pressing it a second time will turn the limit

■ The group of administrators permitted to access the server (based on username black- and whitelists or LDAP groups) when using SSH, Telnet or RDP6 with Network Layer

This high-energy spectral peak is a global feature that can be measured everywhere in the world and is presumably related to seismic surface waves generated by ocean waves (Aki

Yes. Check connection to Control Box. Be sure plug is pushed in all the way. Check hand control connection to Control Box for damaged pins. Check connection cable for damage.