0% found this document useful (0 votes)
20 views27 pages

Statistics Hand written

It was easy to understand

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)
20 views27 pages

Statistics Hand written

It was easy to understand

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/ 27

UNIT – I

INTRODUCTION

What is Visual Basic?


 Visual Basic is event driven programming language. It makes use of Graphical
user Interface for creating powerful applications.
 Visual part refers to the method used to create the Graphical User Interface
(GUI). Basic Part refers to the BASIC programming language
FEATURES OF VISUAL BASIC
 GUI Inter face
 Data Access Features
 Debugging
 ActiveX technologies
 Convert Exe File
GUI Inter face : VB is a Graphical User Interface language. This means that a VB
program will always show something on the screen that the user can interact with to
get a job done.

Data Access Features : Data access features allow to create databases and front –end
applications for most popular database format including MS-Access , SQL server , etc

Debugging: Visual Basic offers two different options for code debugging:- Debugging
Managed Code and Runtime Debugger The Debugging Managed Code individually
debugs C and C++ applications and Visual Basic Windows applications. The Runtime
Debugger helps to find and fix bugs in programs at runtime.

ActiveX technologies: ActiveX technologies allows to use the functionality provided


by other applications such as MS-Word , MS-Excel and other windows applications.

Exe File : We finished applications is a true .exe file that uses a run-time dynamic link
library (DLL) that can freely distribute.

VISUAL BASIC EDITIONS


Visual Basic is available in three versions
1. Learning Edition
2. Professional Edition
3. Enterprise Edition
Learning Edition
Learning edition allows the programmers to easily create powerful
applications for Microsoft Windows 95 and Windows NT. It includes all the controls ,
grid , tab , and Data bound controls.

Unit - I 1 Visual Basic


Professional Edition
The professional edition provides computer professional with full
featured set of tools for developing applications . it includes all the features of
learning edition plus additional ActiveX controls , Internet control and Crystal and
Data Report.
Enterprise Edition
Enterprise edition allows to create robust distributed applications . It
includes all the features of professional edition Plus
 The Automation Manager
 Component Manger
 Data management tools
CREATING AN APPLICATIONS
Creating Applications in Visual Basic means working with projects. A projects
is a collections of files we use to build an applications.
A project consists of :
 One project file that keeps track of all the components ( .vbp)
 The .frm file. One file for each form (.frm)
 One binary data file for each form containing data for properties of controls on
the form (.frx)
 The (.cls) file for each class module. This file is optional.
 The ActiveX control (.ocx) file.

Start a Project in Visual Basic


1. Visual Basic is initiated by using Program options  Microsoft Visual Basic 6.0 
Visual Basic 6.0. Clicking Visual Basic 6.0 icons. Then it opens into a screen.

Unit - I 2 Visual Basic


2. Click on the Standard.EXE from the New project screen. Then it open into visual
basic form window.

 Right on top we see “Project1 – Microsoft Visual Basic [design]. This is the
title of the project we are working on. The title is displayed on the title bar.

Build a Project in Visual Basic

 Adding Controls and changing properties.


 Write program code.
 Save and run the program.
 Build an executable file.

Adding Controls and changing properties

1. Double Click the desired control on the Tool box. That control will appear at
the center of the form.
2. Now we can drag the control and place it at a location of choice.
3. Click anywhere on it and press F4 or select properties window from view
menu or click right mouse button on controls and select properties from
pop-up menu.
4. We can change the caption and name in the properties window.

Unit - I 3 Visual Basic


Write Program Code
1. The next step is code programming step
2. The Code window is viewed by selecting view code from the project
window or by selecting code from view menu or Pressing F7

Example
Private Sub cmd1_click()
Text3.text = val(text1.text) + val (text2.text)
End Sub

Save and Run the Program


1. The Save Project command is selected from the File menu. A file name is
called Display .frm is given and save button has to be clicked.
2. Run visual basic program. Click "Debug" from the menu bar. Click
"Start" from the drop down menu. Alternatively Press F5

Build an executable file


1. We can create an executable file in Visual basic by choosing Make EXE
file command from File menu. A make EXE dialog box appears.
2. Now the file saved as Display .exe in the required directory.

Unit - I 4 Visual Basic


EVENT DRIVEN PROGRAMMING
 Visual Basic programs are built around events. Events are various things that
can be happen in program.
 The common events are Click, DblClick, Load, MouseMove, MouseDown,
MouseUp, KeyPress, KeyUp, KeyDown, GotFocus, LostFocus etc.
 When the user clicks , presses key or moves the mouse, the particular block of
code of the corresponding event procedure is executed. Then the program
behaves in a certain way. This is event driven programming.

Then the code in the click event procedure gets executed. The code instructs to
print a text on the form. After that we see a text printed on the form. This is the
concept of event driven programming. That means , the code is not executed from top
to bottom but it works when the corresponding event procedure is invoked.

VISUAL BASIC IDE (INTEGRATED DEVELOPMENT ENVIRONMENT)


 IDE is a term commonly used in the programming world to describe the
interface and environment that we use to create VB Applications.
 The IDE is also commonly referred as the Design environment or the program.
The visual basic IDE is made up of a number Components
 Menu Bar
 Context Menu
 Tool Bar
 Tool Box
 Project Explorer

Unit - I 5 Visual Basic


 Properties Window
 Form Layout Window
 Form Designer
 Code Editor Window
 Object Browser

MENU BAR
 The Menu bar displays the commands that are required to build applications.
The main menu items have sub menu items that can be chosen when needed.
 Below the Title Bar is the Menu Bar. The Menu bar has the following Menu…

File Menu : To open and save a new or existing project, to print project file.
Edit Menu : For all editing requirement Cut , Paste , Find , Undo , etc.
View Menu : To view the various part of visual basic project
Project Menu : Inserting and removing forms.
Format Menu : For spacing , placing and appearance of controls in form.
Debug Menu : To remove the errors that have crept in
Run Menu : To compile , start and stop the program.
Add-Ins Menu : To add tools like Data Manager , other wizard , etc
Help Menu : For On line help that every programmer needs to refer to

POP-UP MENU (OR) CONTEXT MENU


 The Pop-Up menu is a floating menu that is displayed over a form
independent of the menu bar.
 Pop up menus are also called context menus , because the items displayed on
the pop-up menu depend on where the pointer is located when the right click
button is clicked.
 Any menu can be displayed as a pop up menu at run time provided it has one
menu item.
 For Example , the Pop Up menu displayed when we right click on the Tool Box
lets display the components dialog box , Hide the tool box , Dock or Unlock
the tool box, or Add a custom tab to the tool box.

Unit - I 6 Visual Basic


THE TOOL BOX
The Tool box contains a set of controls that are used to place on a form at
design time thereby creating the User Inter face area. There are 21 controls in General
Tool box. Additional controls can be included in the toolbox by using Components
Menu item on the project Menu.

Pointer :
The Pointer provides a way to move and resize the controls and forms

Unit - I 7 Visual Basic


Label box :
Label displays a text that the user cannot modify or interact with.
Frame :
The Frame control allows to create a graphical or functional grouping controls.
To group controls , draw the Frame first and then draw controls inside the frame.
Text Box :
Text box control is used to display the message and allow the user to edit the
data in the box. A text box control is also called edit field or edit control. It display the
information entered at design time, entered by the user.
Command Button :
Command button carries out the specified action when the user chose it. The
user click on this button and the computer will perform the task associated with the
button.
Check Box :
Check box displays a True or False , or to displays multiple choices when the
user can choose more than once.
Option Button :
It allows the user to select only one option even if it displays multiple choices.
List Box :
The List box displays a list of items from which a user can select one. The list
can be scrolled if it has more items that can be displayed at one time.
Combo Box:
This allows the user to select an item form the drop down list or to type in
selection in the Text box
HScroll Bar & VScroll Bar:
This controls allow the user to select a value within the specified range of
values.
Timer :
Timer controls executes the timer events at specified intervals of time
Picture Box:
A picture box controls can display a graphic from a bitmap , icon , or metafile,
as well as enhanced metafile , JPEG , or GIF files. It clips the graphic if the controls
isn’t large enough to display the entire image.
Image Box:
Images are displayed an Image control can only be decorative and use fewer
resources than a picture box.

Unit - I 8 Visual Basic


Drive , Directory , and File List controls:
 The Drive List box displays the valid disk drives and allows the user to select
one of them.
 Dir List Box allows the user to select the directories and paths. Which are
displayed.
 The File List Box displays a set files from which a user can select the desired
one.
Shape Controls:
Shape controls adds a shape (Rectangle , Square or Circle) to a form
Line Controls:
Line controls draws a straight line to the form.
Data Control:
Data controls enables the user to connect to an existing database and display
information from it.
OLE: (Object Linking Embedding)
OLE controls is used to link or embed an object, display and manipulate data
from other windows based applications.

TOOL BAR
 Tool bar is a collection of buttons , it provide quick access to commonly used
commands in the programming environment.
 We can click a button on the tool bar once to carry out the action represented
that button.

PROJECT EXPLORER
 The Project explorer is located on the right side of the screen, just under the
Tool bar
 It serves as a quick references to the various element of a project namely form,
Classes , and Modules. All of the objects that make up the applications are
packed in a project.
 The Project explorer has three icons on its tool bar
o To View the Code

Unit - I 9 Visual Basic


o To View the Controls
o To View the Folder

PROPERTIES WINDOW
 The Properties window is docked under the Project Explorer Window.
 This window lists all the properties for an object or control used in Visual basic.
Currently the only object is the form1.
 Each and every form in an application is considered an Object. Now, each
object in visual basic has characteristics such as size and color.

Working With Properties Window


The Properties window allows changing the current setting of the control
 In order to access the properties of control
 Click the right mouse button
 Choose the properties option from the Pop up Menu
(or)
Select the controls whose properties we want to see or change and Press F4

Unit - I 10 Visual Basic


Properties Window Elements
The Properties window contains the following elements:
 A drop-down list box at the top of the window, from which you select the
object whose properties you want to view or set.

 Two tabs, which list the properties either alphabetically or by category.

 A description pane that shows the name of the selected property and a short
description of it.

Most commonly used in Properties window


 Name
 Caption
 Back ground Color
 Fore color
 Font
 Height
 Width

FORM LAYOUT WINDOW


The Form Layout window allows positioning the forms in applications using a
small graphical representation of the screen.

CODE EDITOR WINDOW


A separate code editor window is created for each form or code module in our
application. The Programmer can change the font size of the code.

Unit - I 11 Visual Basic


OBJECT BROWSER
 The Object browser allows us to browse through the various properties ,
events and methods that are made available to us.
 Its is selected by selecting Object Browser from the View menu or pressing the
Key F2.
 The left column of the object browser lists the objects and classes that are
available in the projects that are opened and the controls that have been
referenced in them.
 It is possible for us to scroll through the list and select the object or class that we
wish to inspect.

FORMS
 The Form is one of the most basic objects in which the applications is developed.
 The controls have to be placed on the form. A form is a window that contains
applications code and has other objects placed on it to create the User Interface.
 Every form object has its own properties , events and methods associated with
it.
Anatomy of a form
 The Form is the central figure in the IDE. Its has a title bar that contains the title
on the top left – hand corner, Form1.
 There is also icon next to the title. On the top right hand side we will see the
Minimize , Maximize and Close buttons.

Unit - I 12 Visual Basic


Setting Form Properties
A Form in visual basic has as many as 50 properties. Each of these properties
will affect the appearance and behavior of the form in subtle.

Working with the Properties Window


The Properties window allows changing the current setting of the control
 In order to access the properties of control
 Click the right mouse button
 Choose the properties option from the Pop up Menu
(or)
Select the controls whose properties we want to see or change and Press F4

Unit - I 13 Visual Basic


Common Form Properties In VB
Name
Name property, it’s the name by which the form is referred to in code. Visual
Basic by default names the forms as Form1, Form2, etc. Make it a point to give
meaningful name.
Caption
This is the name that appears on the Title Bar of the Form. The caption can be
changed at runtime. The caption must be meaningful and informative to the User.
Picture
The Name of the file that contains the picture to be displayed on the form. This
can be set at design time and also changed at runtime.
Background Color
This property determines the background color of the form. In order to change
the setting of this property , double click on the value on the right. A color palette will
pop up. Select the color of our choice.
Control Box
The value for this is True or False. If its set to true, the Control box is visible on
the top left hand corner of the form. If it is to false , it is not visible and hence is not
accessible by the User.
Min Button and Max Button.
The Value for each of these properties is True or False. Set this to false if we do
not want the User minimize or maximize the form during the runtime.
Font
The font properties for a form include the following
Font Name : Name of the font
Font Bold : if set to True , the text will be displayed in bold
Font size : We can set the size of the text in points
Moveable
This is a property introduced in Visual Basic by setting it to False , it is possible
to prevent the user from moving the window manually.
Mouse Pointer
This property sets the value that indicates the types of mouse pointer displayed
when the mouse pointer appears over a particular area of the object at runtime.
Window State
This property indicates whether the window is shown normally , maximized or
minimized .

Unit - I 14 Visual Basic


FORM METHODS
Forms have methods that are used in code to control their behavior. Visual
basic supports many methods to change the appearance
 Move Methods
 Graphic Methods
 Show Methods
 Hide Methods
Move Methods
It allows the programmer to position the form at a desired location on the
screen.
Syntax
FormName.Move Left[Top],[Width],[Height]
Example
Form1.Move 20, 50, 2000, 2000

Graphic Methods
There are other properties for drawing lines , Circle , clearing the form for any
drawing object
Circle : To draw a circles
Line : To draw a Lines
Pset : To draw a point with a given color at a given location
Point : returns the color of screen at the given location
Show Methods
The Show method of a form displays that form on the screen. The Show
method is typically used to transfer control from one form to another.
Syntax:
Formname.Show
Example:
Form1.show
Using Load Statement
The Load statement is used to load a form or control into memory but
does not display it.
Example
Load form1.
Hide Methods

Unit - I 15 Visual Basic


The Hide method of a form removes the form from the screen (makes it
invisible), but the form still remains in memory.

Example
Form1.Hide
Using Unload Statement
The Unload statement removes the from form the display and release its
memory.
Example
Unload Form1

CONTROLS
Controls are used to place on a form at design time thereby creating the User
Inter face area. There are 21 controls in General Tool box. Additional controls can be
included in the toolbox by using Components Menu item on the project Menu.

Create the Controls on the Form


 Double Click the desired control on the ToolBox. That control will appear at
the center of the form. Now we can drag the controls and place it at a location
of choice.
(Or)
 Put the Command button the form
 Click with the left mouse button on the command button

Unit - I 16 Visual Basic


 Next move the mouse pointer to the location on the Toolbar where we want
the command button on the form
 Hold down the left mouse button and drag in any direction
 Release the left mouse button.

Working With a Controls


 After placed the control on the form , we want to change the location or the
dimension.
 To re-size the controls we are given a total of Eight sizing handles that look like
small Squares.

 The four handles on the four corners are increase are to decrease the length and
breadth of the control
 The two sizing handles on the horizontal edges are used to increases or
decreases the height on the control.
 The two sizing handles on the vertical edges are used to increases or decreases
the Width on the control.
 To move a control to another location , click on the control , hold down the left
mouse button and drag the control to location of choice.

Unit - I 17 Visual Basic


More Work on a Controls
 Click the Right Mouse Button on the Command Button and see a Pop up menu
like one shown
 This menu will help to align the control, view the code written, view the
properties, Cut and Copy the controls and Delete the controls.

 Sometimes one control will overlap another control and likely to spend a great
deal of time looking for it. If the currently visible control is hiding another
control , this option will get enabled.
 Select the Command Button and click on format on the Menu Bar

Command Button Properties


 Appearance
 Back Color
 Caption
 Disable Picture
 Down Picture
 Mask Color

Unit - I 18 Visual Basic


VARIABLES
 Variables are the memory locations which are used to store values
temporarily.
 A variable name must begin with an alphabet letter and should not
exceed 255 characters. It must be unique within the same scope. It should
not contain any special character like %, &, !, #, @ or $.

Declaring Variables
Variables in VB are declared using the DIM statement.
Syntax
Dim VariableName As DataType

 Dim(short for Dimension) – keyword


 Variable name - Name used to refer to variable
 As - keyword
 Data Type - Valid data types in VB

Example
Dim mark as Integer

The Name of Variable:


 The name must being with a letter of the alphabet.
 The name must consist only of letters, digits, and the underscore character.
 The name can be as long as 255 characters.
 Variable names can’t be duplicated with the same scope.

DATATYPES
 Variable have a name and a data type. The data type of variable determines
how the bits / bytes representing those values are stored in the computer
memory.
 All Variables have a data type that determine what kind data they can store.

Visual Basic Data types


S.No Data Types Descriptions
A numeric Variable , holds numeric values
1 Integer
-32,768 to 32,767
A numeric variable , holds a wider range of
2 Long (Long Integer)
integers than integer -2,147,483,648 to

Unit - I 19 Visual Basic


2,147,483,647
A numeric variables , which holds with decimal
places.
3 Single
-3.402823E38 to -1.401298E-45 for Negative
1.401298E-45 to 3.402823E38 for Positive
A numeric variable with a wider range than
4 Double
single.
For holding monetary values
5 Currency
-922,337,203,685,477.5808to 922,337,203,685,477.5808

For Holding Text or string Values


6 String 0 to approximately 2 billion for variable length
1 to approximately 65,400 for fixed length
A numeric Variable , holding less than the value
7 Byte
255 , 0 to 255
8 Boolean For holding True or False values
For holding Date values inclusive of and between
9 Date
January 1,100 to December 31,9999
For holding references to objects in Visual basic
10 Object
and other applications. Any object references
Number required by elements. The range of each
11 User – Defined
element is the same as the range of its data type
A general purpose variable that can hold most
other types of variables. Any numeric value up to
12 Variant
the range of Double. With character values , it has
the same range as for a variable length string.

Object Data Type


 In Visual Basic, forms , controls , procedure and record set are all considered as
objects. All programming activity revolves around these objects. VB is very
much object oriented Programming language , it is very natural use Object
data type.
 An object variable refers to an object within the applications or in some other
application.
 A variable declared as an Object is one that can subsequently be assigned to
refer to any actual object recognized by the application.

Unit - I 20 Visual Basic


Example

Dim objDb As Database


Set objDb = OpenDatabase (“C:\Sri\ss.mdb”)

Variant Data Type


 The variant data type can be used to define variables that contain any type
of data. It accepts text, numeric data.
 If don’t supply a data type, the variable is given the Variant data type by
default.
 A Variant is a special data type that can contain any kind of data except
fixed-length String data

Example : 1
Dim Varvalue As Variant
Varvalue = 23434
Example : 2
Dim Varvalue “ Variant by default”
Varvalue = “100” “ Varvalue contains “100” ( a string )
Varvalue = varvalue – 70 “ Varvalue now contains the numeric value 30

 A Variant can also contain the special values


 Null Value
 Error Value
 Empty Value
Null Value
Null is commonly used in database applications to indicate unknown or
missing data. If we assign Null to a variable of any type other than variant, a
trappable error occurs.
Example
Z = Null

If IsNull (X) Then


Debug.Print…..
End If

Unit - I 21 Visual Basic


Error Value
Error is Special value used to indicate that an error condition has occurred in a
Procedure. An error value is created by converting a real number using the CVErr
function.
Empty Value
A Empty Value is a special value different from 0, a Zero-length string (“”), or
the Null Value.
Example
If IsEmpty (X) Then ………..
 A Variant can be assigned the Empty value using the Empty Keyword

SCOPE OF A VARIABLE
Scope of a variable determines which part of the code can access the
variable. A variable is declared in general declaration section of a module to make it
available to all the procedures in the module.
There are different ways to declare the Variable
 Local Variables
 Static Variable
 Module Level variable

Local Variables
Local variable is one that is declared inside the procedure. This variable is only
available to the code inside the procedure and can be declared using Dim Statement.
Example
Dim mark As Integer
Dim name As String

Static Variables
A static variable continues to exist and retains its most recent value. The next
time code calls the procedure, the variable is not reinitialized, and it still holds the
latest value that assigned to it.
Example
Static mark As Integer
Module Level Variables
 Module level variable is accessible from all the procedures in the module but
not from other modules.

Unit - I 22 Visual Basic


 A module level variable is declared in the Declarations section, at the top of the
module using the Public or Private keyword.
 There is no difference between Dim and Private at the module level.
Public Variable
 Public variables should not be declared within a procedure
 Public variable in different modules can share the same name and
they can be differentiated in code.
Private Variable
 Private Variable should be declared within procedure.
 There is no difference between Dim and Private, but Private is
preferred because it makes the code easier to read.

Declaring Module level variable


Syntax
[Private | Public ] variable name As Data Type
Example
Private intper As Integer
Public inttemp As Integer
CONSTANTS
 Constants are named storage locations in memory. The value of which does not
change during program execution.
 The Const statement is used to create a constant
 Constants can be declared in local , form module , and can be Public or Private
as for variable.
Declaring Constants
Constant in VB are declared using the Const Keyword.
Syntax
[Public | Private] Const constantname [As Type] = expression
 Constant Name is Valid name
 As Type is Data type
 Expression is a numeric or string value that has to be assigned to
constant.
Example
Const pi = 3.1415
Dim rad = Val(Text1.Text)
CircleA = 2 * pi * rad

Unit - I 23 Visual Basic


Scope of Constant
Constant can be declared in the declaration section of a form , standard , or
class module , rather than within the procedure, the constant will be available to all
the procedure in the module.
By declaring Constant using the Public Keyword , it is available throughout the
applications.
Example.
Public Const conA = ConB * 1.414
Public Const conB = ConA * 1.414

DATA TYPE CONVERSION


Visual Basic functions either to convert a string into an integer or Convert text
data into numeric type or numeric data into currency data type.
A Conversion function should always be placed at the right hand side of the
calculations statement.

S.No Conversion function Converts an expression to


1 Cbool Boolean
2 Cbyte Byte
3 Ccur Currency
4 Cdate Date
5 CDbl Double
6 Cint Integer
7 CLng Long
8 CSng Single
9 CStr String
10 Cvar Variant
11 CVErr Error

ARRAYS
Array is a set of similar items. All items in an array have the same name and
are identified by an Index.
Syntax
Dim Varname [([Subscripts])] as [New]type [,varname…]

Unit - I 24 Visual Basic


There are two types of array in Visual Basic
 Fixed size array ( The Size of array always remains the same)
 Dynamic array ( The size of can be changed at run time)
Fixed Size Array
Fixed array can be declared by giving a name to the array with the upper limit
in the parentheses. The upper limit should always be within the range of Long data
type.
Declaring Fixed-Size Array
1. To create a local array , use the Private statement in a procedure to declare
the array.
Dim counters (10) As integer
2. To create a Module – level array , use the Private statement in the Declaration
section of a module to declare the array
Private counter (10) As Integer
3. To create a public array , use the public statement in the Declarations section
of a form.
Public counter (10) As Integer

Example Program
Dim studentName(10) As String
Dim num As Integer
Private Sub addName()
For num = 1 To 10
studentName(num) = InputBox("Enter the student name", "Enter Name")
If studentName(num) <> "" Then
Form1.Print studentName(num)
Else
End
End If
Next
End Sub
Private Sub Command1_Click()
addName
End Sub

Unit - I 25 Visual Basic


Multi Dimensional Array
Array can have more than one dimension. A table of data will be represented
by a multidimensional array. For example to hold the student registration number
and marks of the students, we need to mention X any Y co-ordinate.
Syntax
Dim Varname (Subscript1,Subscript2…..Subscript n) As Data type

Example
1. Dim Marks (50 , 50 ) As Integer
2. Dim Marks ( 101 To 200, 1 To 100)
3. Dim Details( 101 To 200, 1 To 100, 1 To 100)

Dynamic Array
 Dynamic arrays differ from fixed arrays because a subscript range for the array
elements is not specified when the array is dimensioned.
 A dynamic array can be resized at any time.
 The subscript range is set using the ReDim statement

Declaring Dynamic Array

1. Declare the array with a Public statement or Dim statement at the module level
or a Static or Dim statement in a procedure

Dim DynArray()

2. Allocate the actual number of elements with a ReDim statement.

ReDim ArrayName(Subscript) As DataType

 ReDim is the keyword that denotes we are redimensioning an array.


 ArrayName is the name of the array.
 Subscript is the dimensions of the array.
 DataType is any valid data type. The data type cannot be changed from its
initial declaration when using the ReDim keyword

Example

Dim salval () As Integer

Dim months As Integer

Unit - I 26 Visual Basic


Dim Dep As Integer

Months = 12

Dep = 6

ReDim Salval (Months , Depts)

The Preserve Keyword


Each time on executing the ReDim statement, the current data stored in the
array is lost and the default value is set. But if we want to change the size of the array
without losing the previous data , we have to use the Preserve keyword within the
ReDim Statement.

Example

ReDim Preserve Salval (12 , 9)

Unit - I 27 Visual Basic

You might also like