0% found this document useful (0 votes)
6 views26 pages

Second

Uploaded by

HEMANTH HP
Copyright
© © All Rights Reserved
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)
6 views26 pages

Second

Uploaded by

HEMANTH HP
Copyright
© © All Rights Reserved
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/ 26

UNIT – II

THE CODE WINDOW


 Visual Basic provides the code window to compose (View, Write, Edit) all visual
basic Application code, as there are modules and cut and paste code between
them.
 The Code window has probably all the features that programmers will hope for.

Opening the Code Window


 Open the Code window by pressing the Right mouse button on the control.
Choose the “View Code “ Option
 OR Press F7 after the clicking on the Control
 OR Click on view in the menu bar and click view code.
 OR right click the name of the form from the project explorer and select
view code.

Parts of the Code Window (OR) Anatomy of Code Window


Project Name
The name of the project to which this procedure belongs is displayed in the title
bar.
Module Name
A project can contain more than one module (A form is also module) , therefore ,
while editing the code it would be very helpful to know the name of the module whose
code is being edited.
Object Box
This displays all the objects associated with that form and the form itself. The
open the code window F7, it displays the name of the controls selected.

Unit - II 28
Visual Basic
Click on the “down arrow” to display the names of all the controls associated
with the form.
Event Box
This will list all the events recognized by visual basic for the controls or form
displayed in the object box. When we select an event , the event procedure associated
with that event name is displayed in the code window.
Split Bar
 Use the split bar to view different parts of the code. Each part can be
independently scrolled at the same time.
 Click on “Windows” on the menu bar. From the drop down menu select “Split”
this will split the code window into two horizontal panes.
 Double click on the bar to close the pane or move the split bar to the bottom of
the code window.
Margin Indicator Bar
The gray area on the left side of the code window is the margin indicator.
Procedure View Icon
Displays the selected procedure. Only one procedure at a time is displayed in the
code window.
Full module view icon
Displays the entire code in the module
The Procedure Separator
It is a horizontal gray line that separates two procedures. It can be turned on or
off.

PROCEDURES

A Procedure is a block of Visual Basic statements enclosed by a declaration statement


(Function, Sub) and a matching End declaration. All executable statements in Visual Basic
must be within some procedure.

Benefit of Using Procedure


 It is easier to debug a program with procedures.
 Procedures used in one program can act as building blocks for other programs
slight modifications.

Anatomy of a Procedure

The Procedure is the piece of code that gets executed when the control that it is
associated with sense an event.

Unit - II 29
Visual Basic
A Procedure consists of all or Most of the following.

 Name

 Declaration Area

 Statements

 Call to other procedure (or) Functions

 Terminator

Name
Every procedure must have a name. The name of a procedure is usually tied to
control. Example o procedure called cmd_click(). This means that this procedure will
be executed against the ‘Click’ event of the Cmdexit button.
Declaration Area
Declaration area is used to make all the declaration for variables, Constant, etc.
This makes it easy to locate variables and verify the same during the process od
debugging.
Declaration Area
The procedure deals with basic execution. A procedure will contain VBA
statements that will perform the intended task.
Call to other procedure (or) Functions
One way of reducing the number of lines in a procedure is to break up the entire
activity into smaller functions or procedures that can be called as and when required.
The principle used here is “Write once – Use many times”. A call to another procedure
or function is not a must for every procedure.
Terminator
Every procedure is terminated by the “End Sub” statement

Example :

Unit - II 30
Visual Basic
Sub Procedure
A Sub procedure is a series of Visual Basic statements enclosed by
the Sub and End Sub statements. The Sub procedure performs a task and then returns
control to the calling code, but it does not return a value to the calling code.

Each time the procedure is called, its statements are executed, starting with the
first executable statement after the Sub statement and ending with the first End
Sub, Exit Sub, or Return statement encountered.

We can define a Sub procedure in modules, classes, and structures. By default,


it is Public, which means we can call it from anywhere in application that has access to
the module, class, or structure.

Syntax

[Private | Public [Static] Sub Procedure name [(Argument List)]


Statement
End Sub

Example
Sub Operator (ByVal task As String)
Dim stamp As Date
stamp = TimeOfDay()
MsgBox("Starting " & task & " at " & CStr(stamp))
End Sub

Function Procedure
 A Function procedure is a series of Visual Basic statements enclosed by
the Function and End Function statements.
 The Function procedure performs a task and then returns control to the calling
code. When it returns control, it also returns a value to the calling code.
 Each time the procedure is called, its statements run, starting with the first
executable statement after the Function statement and ending with the first End
Function, Exit Function, or Return statement encountered.
 We can define a Function procedure in a module, class, or structure. It
is Public by default, which means we can call it from anywhere in VB application
that has access to the module, class, or structure.
 A Function procedure can take arguments, such as constants, variables, or
expressions, which are passed to it by the calling code.

Unit - II 31
Visual Basic
Syntax

Function FunctionName [(ParameterList)] As ReturnType


[Statements]
End Function

Example
Function sum (int1 as integer , int2 as integer ) as integer
Sum = int1 + int2
End function

The function ‘sum’ can be called anywhere in the program. It can be called by
simply passing the variables to it as argument.

Dim intnum1 as integer , intnum2 as integer


Dim intans as integer
Intans = sum(intnum1 , intnum2)

CONTROL STRUCTURES
Control structures are used to control the flow of program’s execution. Visual
Basic supports control structure such as
 If….Then
 If….Then….Else
 Select…..Case
 For…..Next
 Do [{While | Until} Condition]…..Loop
 While…..Loop

If….Then Statement
The If...Then selection structure performs an indicated action only when the
condition is True; otherwise the action is skipped.

Syntax

If <condition> Then
statement
End If

Unit - II 32
Visual Basic
Example

If average>75 Then
Text1.Text = "A"
End If

If….Then…..Else Statement
The statement is executed only if the condition is True, the statement1 is
executed, otherwise the Else part is executed.
Syntax

If <condition > Then


statement1
Else
statement2
End If

Example

If average > 50 Then


Text1.Text = "Pass"
Else
Text1.Text = "Fail"
End If

How does it works

 The first statement evaluates the expression


 If an expression returns a True value the statements after the THEN keyword are
executed.
 If the expression return a False , the rest of the ElseIF conditions are evaluated by
turn.

Select Case…..End Select


This method is used when the program has to execute one of several groups of
statements, depending on the value of expression.

Unit - II 33
Visual Basic
Syntax
Select Case testexpression
[Case Expressionlist – n
[Statements-n]]…
[Case Else
[Elsestatements]]
End Select

Example

Select Case Age


Case <=18
MsgBox “Juniors”
Case <=50
MsgBox “Seniors”
Case Else
MsgBox “Oldies”
End Select

How does it works

 The test expression is evaluated with the case expression


 If the two match, the statements following that case, upto the next Case or
End select in the case of the last clause is executed.
 If the two do not match, the test expression is evaluated with the next case
expression.
 If more than one case expression matches with the test expression, the
statement of the first case only are executed.
 If there are no matches , program execution continues with the statement
after the End select.

Looping Statement

For…..Next Statement
This statement is used to execute a statement or a block of statement a certain
number of times.

Unit - II 34
Visual Basic
Syntax
For counter [ As datatype ] = start To end [ Step ]
[ statements - 1 ]
----------
----------
[statements – n]
Next [ counter ]

Example
For I = 1 to 10
Total = total + I
Next I
How does it works
 The For statement initializes the value of I as 1. Since 1 is less than 10, the next
statement is executed.
 The statement Total = Total + I is executed
 The statement Next I increments the value of I by 1.
 The control shifts to the beginning of the loop, where the value of I is checked.
 If the value of I is more than 10, the loop terminates,.

Do [{While | Until} Condition]…..Loop


This structure is used when we want the program to repeat a block of statement
while condition is True.

Syntax
Do [ {While | Until } Condition ]
[Statements]
[Exit Do]
Loop

Example
I =1
Do While I < 10
Sum = sum + I
I=I+1
Loop

Unit - II 35
Visual Basic
How does it works
 The value of I is initialized to 1.
 The exit condition is first checked to see of I is less than 10. if I is less than 10,
then the statements in the loop are executed.
 Sum = Sum + 1 and I = I + 1 are executed
 The keyword Loop returns the controls to the Do While …. Statement , where
the exit condition is checked.

While Loop Statement


This structure executes a series of statements as long as given condition is true.

Syntax
While condition
[statements]
Wend

Example
Dim I as Integer
I =1
While I < 10
I = sum + 1
I = I+1
Wend

How does it works


 While checks the condition. If it is true the statement are executed
 When the program encounters the Wend statement, the control returns to
while.
 If the condition returns true , the process is repeated
 If the condition is false, statement following the Wend is executed.

Do…Loop While statement


The Do…Loop While statement first executes the statement and then tests the
condition after each execution.

Unit - II 36
Visual Basic
Syntax
Do
Statement – 1
----------------
---------------
Statement – n
Loop While condition
Example
Counter = 200
Do
Text1.text = str (counter)
Counter = counter + 1
Loop While counter < 501

FILES
File System Controls
There are three File System Controls in Visual Basic
 Drive List Box ( Moving from one drive to another)
 Dir ListBox ( Moving from one directory to another)
 File List Box ( List files in a directory)

The Drive ListBox Control


This is a drop-down list box that will display the list of drives in the computers.
It gets all information from the operating system and allows the user to select a drive
of his choice. Selecting a particular drive records in the Drive property of the Drive List
Box.

The DirList Box Control


A drop-down list box that displays a hierarchical list of directories in the current
drive.

The File List Box


Displays all files in the current Directory or Folder. Allows user to set up search
criteria for files.

Unit - II 37
Visual Basic
Phase – I
Open a form and create the following controls on it
The DriveListBox
The DirListBox
The FileListBox

Setting the relationship


Add the following code
Private Sub Drive_Change ()
Dir1.Path = Drive1.Drive
End Sub
This lines establishes a connection between the DriveListBox and the DirListBox ,Such
that the directories for the selected drive are displayed.
Private Sub Dir1_Change ()
File1.Path = Dir1.Path
End Sub
This lines establishes a connection between the DirListBox and the FileListBox , such
that all the files in the selected directory are displayed.

File Management Functions (Or) File Commands


S.No Commands Descriptions
1 ChDrive Changes the current logged drive

Unit - II 38
Visual Basic
2 ChDir Changes the default directory
3 MkDir Creates a new directory
4 RmDir Deletes a directory
5 Name Renames a files
6 Kill Deletes a file
7 FileCopy Copies source file to destination
8 FileDateTime Returns the date & time when the file was modified
9 GetAttr Returns the attributes of file as an integer value
10 SetAttr Sets the attributes of a file

ChDrive : Change the current logged drive


Syntax
ChDrive drive
Example
Chdrive “A”
This will change the drive to “A”
ChDir : Change the current directory or folder
Syntax
ChDir Path
Example
ChDir “C:\Sri\Svm
This will change the current directory to “C:\Sri\Svm
MkDir : Creates a new directory or folder
Syntax
MkDir Path
Example
MkDir “C:\Svm\sri”
This will create a directory Sri under ‘c:\svm’
RmDir : Deletes a directory
Syntax
RmDir Path
Example
RmDir “C:\Temp\Temp1”
Name : Renames a disk file , directory , or folder
Syntax
Name oldname as Newname

Unit - II 39
Visual Basic
Example
Name Oldfile as Newfile
Old file is renamed as newfile
Kill : Deletes a file or files
Syntax
Kill Pathname
Example
Kill “textdoc” ‘ To delete the file ‘textdoc’
Kill “*.Doc” ‘ To delete all the “*.Doc” files in the current directory
FileCopy : Copies the source file to the specified destination
Syntax
FileCopy Source , Destination
Example
FileCopy Maxfile Highfile
This will copy the contents of the Maxfile to Highfile
FileDateTime : Returns the date & time when the file was modified
Syntax
FileDateTime (Pathname)
Example
Dated = FileDateTime (“Maxfile”)
This will return the date and time when the file ‘Maxfile’ was last modified.
GetAttr : Returns the attributes of a file as an integer value
Syntax
GetAttr (Pathname)
Example
Dim Fileattrib as Integer
Fileattrib = GetAttr (Maxfile)
SetAttr : Sets the attributes of a file
Syntax
Setattr Pathname , attributes
Example
Setattr Highfile , Vbhidden + Vbsystem
This will set the attributes of the file as Hidden and System

Unit - II 40
Visual Basic
Types of Files
From the programming point of view files are classified as
 Sequential Access files
 Random Access files
 Binary Access Files

Working With Files


Working with any type of file will need to
 Open a file
 Reading a file
 Writing a file
 Close the file
Sequential File
Sequential access files are accessed line by line and are ideal for application that
manipulates text files.

Opening a Sequential file


A sequential file is ca collection of ASCII characters. A sequential file need not
have its data written in any specific structure.

Syntax
Open Pathname for Input As [ # ] filenumber

 Open is the command to open the file.


 Pathname is the full pathname of the file to be opened
 Input specifies that the file must be opened for reading purpose
 File number is the number assigned to the file for purposes of
Identifications.
 The filenumber must be Unique. The range is form 1 to 511.

Example
C:\Svm\Master.txt for Input As #1

 C:\Svm\Master.txt for Input As #1 is the full pathname of the file


 The Input keyword is that the file being opened for reading.
 #1 is the file identifier. This number will identify this file it is closed.

Unit - II 41
Visual Basic
Closing a File
A file must be closed for the operating system to write the data from the
associated buffer to the file.
Syntax
Close [ FileNumber List ]

 Close is the command


 FilenumberList is the list of the filenumber that represent the files that
have to be cloased
 The filenumber will be returned to a list that is displayed by the function
“Free File”.

Example
Close #1

Free File Function


This functions returns a free file number that is available
Syntax
FreeFile [ rangenumber]

 FreeFile is the function name


 Rangenumber can be 0 or 1. if ‘0’ then it returns a number between
1 and 255. if ‘1’ then it returns a number between 256 to 511.
Example
Dim filenum As Integer
Filenum = FreeFile (1)
Open c:\Svm\Master.txt for Input As #fileNum

Reading a File
The Read operation transfer the contents of the file from the disk to the buffer.
The Input function provided by visual basic reads a sequential files contents into the
buffer.
The Input functions has three options
 Input
 Input#
 Line Input #

Unit - II 42
Visual Basic
1. Input
Syntax
Input ( number , [#] filenumber )
 Input is the command name
 Number is the number of character to read
 Filenumber is the number of the open file that has to be read.
Example
String1 = Input ( 25 , #1)
2. Input #
Syntax
Input #filenumber , varlist
 Filenumber is the file number of the file to be read
 Varlist is the list of variable that will hold the data
Example
Input #1 , serialNum , Name , Designation
3. Line Input #
Syntax
Line Input #filenumber , databuffer
 Line means read the entire line
 Filenumber is the number of the file to be read
 Databuffer is the variable that will hold the line that has been
read.
Example
Line Input #1 , linebuffer

Writing a File
We have finished with opening , closing and reading a sequential file , let us take
a look at writing to a file.
Before we write to the file , we need to decide if we want to
 Creates a file if does not already exists
 Overwrites the existing contents if the file is opened in ‘Output’
mode.
 Appends new data if the file is opened in ‘Append’ mode.

Syntax 1:
Open Pathname for Append as #1

Unit - II 43
Visual Basic
 Open is the command to open the file
 Pathname is the filename of the file
 Append is the keyword to open the file in append mode
 #1 is the filenumber of the file to be written into.
Syntax 2:
Print #filenumber , Outputlist
 Print is the command to write the data to the file
 Filenumber is the number of the file that has to be written
 Output consists of the data to be written , and argument to
position the data correctly.

Random Access File


Random files are record-based files with an internal structure that supports
"direct access" by record number. This means that program can read from or write to
a specific record in a random access file.

Opening a Random Access file


Syntax
Open pathname [ For FileMode ] As [#] filenumber [len = length]

 Open is the command name


 Pathname is the full name of the file
 FileMode is the mode to open the file
 Len is the length of the record.

Example
Open c:\Svm\Stud.dat for Random As #1 len = 45

Closing a File
A file must be closed for the operating system to write the data from the
associated buffer to the file.
Syntax
Close [ FileNumber List ]
Example
Close #1

Reading a File
Read a record from the file we use the “Get” Command

Unit - II 44
Visual Basic
Syntax
Get [#] filenumber , [ recordnumber] , variable name

 Get is the command


 Filenumber is the number of the file that has been opened
 recordnumber is the number of the record that we want to read
 varaiableName is the name of the variable that will hold the record.

Writing to Random Access file


We can write to random access file , using the “Put” Command. Put (Writes data
from a variable to disk file).

Syntax
Put [#] filenumber , [recnumber] , varname
 Put is the command
 Filenumber is the file number has been opened for writing
 Recnumber where the writing begins
 Varname is the variable that contains data to be written to the disk.

Example
Put #1 , 12 , myrecord

Binary Access File


 Binary Access files are accessed byte by byte. Once a file is opened for binary
access we can read from and write to any byte location in the file.
 Binary files do not store data as fixed length records. Saving an integer value ,
takes only two bytes.
Declaration for Binary files
Type StudeRec
StudId as Integer
StudeName as String
End Type
Opening a Random Access file
Syntax
Open pathname For mode [Access access] [lock] As [#]filenumber [Len=reclength]

 Open is the command name


 Pathname is the full name of the file

Unit - II 45
Visual Basic
 FileMode is the mode to open the file
 Len is the length of the record.
Example
Open c:\Svm\Stud.dat for Binary As #1 len = 45

Closing a File
A file must be closed for the operating system to write the data from the
associated buffer to the file.
Syntax
Close [ FileNumber List ]
Example
Close #1

Reading from a Binary File


The Get statement is used read data from a file opened in binary mode.
Syntax
Get [#]filenumber, [byte position], varname

 Get is the command


 Filenumber is the number of the file that has been opened
 Byte position is the byte position within the file at which the reading
begins.
 Varname is a string variable into which the data will be read.
Example
Get #intMyFile, , strData

Writing to Binary Access file


The Put statement is used write data to a file opened in binary mode.
Syntax
Put [#]filenumber, [byte position], varname

 Put is the command


 Filenumber is the number of the file that has been opened
 Byte position is the byte position within the file at which the writing
begins.
 Varname is a string variable into which the data will be written.

Example
Put #intMyFile, , strData

Unit - II 46
Visual Basic
File System Object Model
The File System Object model provides an object – based tool for working
with folders and files. Using the object. method the user can create , alter , move ,
and delete folders, detect if particular folder exist , and if so , where.

Working with the File System Object


There are three steps involved
1. Dimension a variable as a file system object
2. Use the relevant methods on the object
3. Access the object’s properties
Step1: Creating the File System Object
There are two ways
1. Dimension a variable as type File System Object
Dim fil As a New File System object

This creates an instances of the object as FileSystemObject. The object will be referred
to as ‘fil’.
2. Use the Create Object method to create a File System Object
Set fil = CreateObject (“Scripting.FileSystemObject”)

Step2: Using the Appropriate Method


Create a form and add a button to it alternatively, create a from and add a button
and a text box.
Add the following code to the command button click event
Private sub command1_click()
Dim fso , foldr , fldr1 , s , sfoldr
Set fso = CreateObject (“Scripting.FilesystemObject”)
Set foldr = fso.GetFolder (“c:\”)
Set sfoldr = foldr.subFolders
S = s & fldr1.Name
S = s & VbCrLf
Next
Debug.Print s
End Sub

Unit - II 47
Visual Basic
Step3: Access the Object’s Properties
Once we have a handle to an object , we can access its properties.
Set fldr = fileobj.GetFolder (“c:\”)
Debug.Print “Folder name is “ , fldr.Name

Creating Files and Adding Data With File System Objects


We can create a text file using one of the following ways.
1. The Create Text File method. To create an empty text file
Dim fileobj As New FileSystemObject , fil As file
Set fil = fileObj.CreateTextFile (“C:\Svm.txt”,True)

2. The OpenTextFile method of the FileSystemObject with the writing flag set
Dim fileobj As New FileSystemObject , fil As file , nts as New textstream
Set nts = fileobj.openTextFile (“C:\test.txt”, ForWriting)

Reading and Adding data to the file


Create a text file. Add some data to this file. Create a form and add a command
button and a text box control to it. Set the properties for the text box such that it can
display multiple lines.
Add the following code to the command button click event

Private sub Command1_click()


Dim fileobj As New FileSystemObject , txtfile As File , fill
Filename = text12.text
Set fill = fileobj.GetFIle (filename)
Msgbox “Reading file “ & filename
Set ts - fill.OpenAstextStream (ForReading)
S = ts.ReadAll
Text1.Text = s
Ts.close
End Sub

Writing Data to File


To the same form , add another command button. Now we will read a file and
then write its contents to another file.
Add the code to the second Command Buttons click event

Unit - II 48
Visual Basic
Private Sub Command2_Click()
Dim fileobj , txtfile , filename As string
Set fileobj = CreateObject (“Scripting.FileSystemObject”)
Filename = Text2.Text
Set txtfile = fileobj.CreateTextFile (“C:\” & filename , True)
Txtfile.Write s
Txtfile.WriteBlanklines (3)
Txtfile.Close
End Sub

Moving , Copying , and Deleting Files


The object model has two methods each for moving , copying and deleting files.

Task Method
Move a File File.Move or FileSystemObject.MoveFile
Copy a file File.Copy or FileSystemObject.CopyFile
Delete a file File.Delete or FileSystemObject.DeleteFIle

Set txtfill = fileobj.GetFIle (“C:\filecreated”)


Txtfill.Copy (“C:\copiedfile.txt”)

MENUS
 Menus contains a number of options, logically organized and easily accessible
by the user.
 Windows – based applications follow the standard of a File menu on the left ,
then optional menus a such as Edit , and Tools, followed by Help on the right.
 When the user clicks a menu option, a list of option is displayed. Clicking on any
item on the list will generate a click event.
 Visual Basic provides a very simple methods to create menus for VB applications.
We can create menus using the Menu Editor.

The Menu Editor


 A menu editor can be used to add new commands to the existing menus, create
new menus and menu bars , change or delete existing menus and menu bars.

Unit - II 49
Visual Basic
 A menu editor can be added only after opening a project.
 Menu editor command is chosen from the Tool menu or the menu editor button
is clicked in the Tool Bar.

The Menu Editor has the following items

1. Caption Box : What we type here is what the user sees.


2. Name Box : The name entered here is the control name for the menu item. We can
enter the code for menu item under this control name
3. Shortcut Box : Enter the shortcut keys for the menu items here. Click on the down
arrow , a drop down list box will be displayed with all shortcut keys.
4. Checked Check Box : Click on this , if we want to display a tick mark to show that a
menu item has been selected. The default is off.
5. Enabled Check Box : Click on this to make a menu item enabled. If a menu item is
enabled. It will respond to the mouse click.
6. Visible Check Box: If it is set to Off then the menu item and its sub-menus will not
be visible.
7. Text Window : This gives a preview of what we have entered. We can also view the
hierarchy of menus and sub menus by looking at the indentations.
8. Left Arrow : The left arrow button brings the menu item one level up
9. Right Arrow : Clicking on the Right Arrow moves the menu one level deeper
10. Up Arrow : The Up Arrow interchange the current line with the line above
11. Down Arrow : The down arrow interchanges the current line with line below.
12. Index : Allows to assign a numeric value that determine the control position within
the control array. This position isn’t related to the screen position.

Unit - II 50
Visual Basic
13. Help Context ID: Allows to assign a unique numeric value for the Context ID. This
value is used to find the appropriate help topic in the help file identified by the Help
file property.
14. Negotiate Position : This property determine whether and how the menu appears
in the container form.
15. Next : Moves selection to the next line
16. Insert : Inserts a line in the list box above the currently selected line
17. Delete : Deletes the currently selected line
18. OK : Closes the menu editor and applies all changes to the last form we selected
19. Cancel : Closes the Menu Editor and cancels all changes.

ADDING THE TOOL BAR


 Tool bar is a collection of buttons , it provide quick access to commonly used
commands in the programming environment. For Example , the icon with
scissors represents the action ‘Cut’.
Tool Bar Conventions
One should keep in mind that a ToolBar is a supplement to the Menu Bar. It
offers mouse shortcuts for frequently used functions.

Create a Tool Bar


 Place the mouse on the ToolBox and click the right mouse button
 From the Pop-up menu choose components
 A window pops up displaying the controls that are available
 Click on Microsoft Windows Common Controls
 Click on Wang image edit control

Now Double click on the ToolBar Control. A long flat button will appear on the form
below the menu bar.

Unit - II 51
Visual Basic
There are three options.
 General
 Buttons
 Picture
General
Using this options we can set the mouse pointer type, adjust the size of the
buttons, and set other parameters.
Buttons
In this option , we can insert the buttons , set the control keys for the button
provide the ToolTip text , etc.
Picture
View the picture of the icon selected.

Pasting Icons on Buttons


Double click on the Image Edit control on the Toolbox. A button with picture of
an hourglass will appear.
Bring the property pages of this control by clicking the right mouse button and
selecting properties from the pop-up menu.

There are three options


General
Specify the size of the image under this option
Images

Unit - II 52
Visual Basic
Insert or add the images to the image list. Click the image button. Select the icon
we want. The selected icon will be displayed in the Image list
Color
We can modify the color we can choose.

Unit - II 53
Visual Basic

You might also like