software world tip all about given knowledge and tip share for software language, software programming with various topic in it
Saturday, 25 August 2018
Wednesday, 22 August 2018
Variables declaration in VB
Variables are the memory locations which are used to store values temporarily. A defined naming strategy has
to be followed while naming a variable. 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 $.
There are many ways of declaring variables in Visual Basic. Depending on where the variables are declared and
how they are declared, we can determine how they can be used by our application. The different ways of
declaring variables in Visual Basic are listed below and elucidated in this section.
Explicit Declaration
Using Option Explicit statement
Scope of Variables
Explicit Declaration
Declaring a variable tells Visual Basic to reserve space in memory. It is not must that a variable should be
declared before using it. Automatically whenever Visual Basic encounters a new variable, it assigns the default
variable type and value. This is called implicit declaration. Though this type of declaration is easier for the user,
to have more control over the variables, it is advisable to declare them explicitly. The variables are declared
with a Dim statement to name the variable and its type. The As type clause in the Dim statement allows to
define the data type or object type of the variable. This is called explicit declaration.
Syntax
Dim variable [As Type]
For example,
Dim strName As String
Dim intCounter As Integer
Using Option Explicit statement
It may be convenient to declare variables implicitly, but it can lead to errors that may not be recognized at run
time. Say, for example a variable by name intcount is used implicitly and is assigned to a value. In the next step,
this field is incremented by 1 by the following statement
Intcount = Intcount + 1
This calculation will result in intcount yielding a value of 1 as intcount would have been initialized to zero. This
is because the intcount variable has been mityped as incont in the right hand side of the second variable. But
Visual Basic does not see this as a mistake and considers it to be new variable and therefore gives a wrong
result.
In Visual Basic, to prevent errors of this nature, we can declare a variable by adding the following statement to
the general declaration section of the Form.
Option Explicit
This forces the user to declare all the variables. The Option Explicit statement checks in the module for usage of
any undeclared variables and reports an error to the user. The user can thus rectify the error on seeing this error
message.
The Option Explicit statement can be explicitly placed in the general declaration section of each module using
the following steps.
Click Options item in the Tools menu
Click the Editor tab in the Options dialog box
Check Require Variable Declaration option and then click the OK button
to be followed while naming a variable. 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 $.
There are many ways of declaring variables in Visual Basic. Depending on where the variables are declared and
how they are declared, we can determine how they can be used by our application. The different ways of
declaring variables in Visual Basic are listed below and elucidated in this section.
Explicit Declaration
Using Option Explicit statement
Scope of Variables
Explicit Declaration
Declaring a variable tells Visual Basic to reserve space in memory. It is not must that a variable should be
declared before using it. Automatically whenever Visual Basic encounters a new variable, it assigns the default
variable type and value. This is called implicit declaration. Though this type of declaration is easier for the user,
to have more control over the variables, it is advisable to declare them explicitly. The variables are declared
with a Dim statement to name the variable and its type. The As type clause in the Dim statement allows to
define the data type or object type of the variable. This is called explicit declaration.
Syntax
Dim variable [As Type]
For example,
Dim strName As String
Dim intCounter As Integer
Using Option Explicit statement
It may be convenient to declare variables implicitly, but it can lead to errors that may not be recognized at run
time. Say, for example a variable by name intcount is used implicitly and is assigned to a value. In the next step,
this field is incremented by 1 by the following statement
Intcount = Intcount + 1
This calculation will result in intcount yielding a value of 1 as intcount would have been initialized to zero. This
is because the intcount variable has been mityped as incont in the right hand side of the second variable. But
Visual Basic does not see this as a mistake and considers it to be new variable and therefore gives a wrong
result.
In Visual Basic, to prevent errors of this nature, we can declare a variable by adding the following statement to
the general declaration section of the Form.
Option Explicit
This forces the user to declare all the variables. The Option Explicit statement checks in the module for usage of
any undeclared variables and reports an error to the user. The user can thus rectify the error on seeing this error
message.
The Option Explicit statement can be explicitly placed in the general declaration section of each module using
the following steps.
Click Options item in the Tools menu
Click the Editor tab in the Options dialog box
Check Require Variable Declaration option and then click the OK button
Basic data types of Visual Basic
By default Visual Basic variables are of variant data types. The variant data type can store numeric, date/time or
string data. When a variable is declared, a data type is supplied for it that determines the kind of data they can
store. The fundamental data types in Visual Basic including variant are integer, long, single, double, string,
currency, byte and Boolean. Visual Basic supports a vast array of data types. Each data type has limits to the
kind of information and the minimum and maximum values it can hold. In addition, some types can interchange
with some other types. A list of Visual Basic's simple data types are given below.
1. Numeric
Byte Store integer values in the range of 0 – 255
Integer Store integer values in the range of (-32,768) - (+ 32,767)
Long Store integer values in the range of (- 2,147,483,468) - (+ 2,147,483,468)
Single Store floating point value in the range of (-3.4x10-38) - (+ 3.4x1038)
Double Store large floating value which exceeding the single data type value
Currency Store monetary values. It supports 4 digits to the right of decimal point and 15
digits to the left
2. String
Use to store alphanumeric values. A variable length string can store approximately 4 billion characters
3. Date
Use to store date and time values. A variable declared as date type can store both date and time values and it can
store date values 01/01/0100 up to 12/31/9999
4. Boolean
Boolean data types hold either a true or false value. These are not stored as numeric values and cannot be used
as such. Values are internally stored as -1 (True) and 0 (False) and any non-zero value is considered as true.
5. Variant
Stores any type of data and is the default Visual Basic data type. In Visual Basic if we declare a variable
x
string data. When a variable is declared, a data type is supplied for it that determines the kind of data they can
store. The fundamental data types in Visual Basic including variant are integer, long, single, double, string,
currency, byte and Boolean. Visual Basic supports a vast array of data types. Each data type has limits to the
kind of information and the minimum and maximum values it can hold. In addition, some types can interchange
with some other types. A list of Visual Basic's simple data types are given below.
1. Numeric
Byte Store integer values in the range of 0 – 255
Integer Store integer values in the range of (-32,768) - (+ 32,767)
Long Store integer values in the range of (- 2,147,483,468) - (+ 2,147,483,468)
Single Store floating point value in the range of (-3.4x10-38) - (+ 3.4x1038)
Double Store large floating value which exceeding the single data type value
Currency Store monetary values. It supports 4 digits to the right of decimal point and 15
digits to the left
2. String
Use to store alphanumeric values. A variable length string can store approximately 4 billion characters
3. Date
Use to store date and time values. A variable declared as date type can store both date and time values and it can
store date values 01/01/0100 up to 12/31/9999
4. Boolean
Boolean data types hold either a true or false value. These are not stored as numeric values and cannot be used
as such. Values are internally stored as -1 (True) and 0 (False) and any non-zero value is considered as true.
5. Variant
Stores any type of data and is the default Visual Basic data type. In Visual Basic if we declare a variable
x
without any data type by default the data type is assigned as default.
VB controls
1) Label
Label controls to provide a descriptive caption and possibly an associated hot key for other controls, such as
TextBox, ListBox, and ComboBox, that don't expose the Caption property. In most cases, you just place a Label
control where you need it, set its Caption property to a suitable string (embedding an ampersand character in
front of the hot key you want to assign), and you're done. Caption is the default property for Label controls.
Other useful properties are BorderStyle(if you want the Label control to appear inside a 3D border) and
Alignment (if you want to align the caption to the right or center it on the control). In most cases, the alignment
depends on how the Label control relates to its companion control: for example, if the Label control is placed to
the left of its companion field, you might want to set its Alignment property to 1-Right Justify. The value 2-
Center is especially useful for stand-alone Label controls.
You can insert a literal & character in a Label control's Caption property by doubling it. For example, to see
Research & Development you have to type &Research && Development. Note that if you have multiple but
isolated &s, the one that selects the hot key is the last one and all others are ignored. This tip applies to all the
controls that expose a Caption property. (The & has no special meaning in forms' Caption properties, however.)
If the caption string is a long one, you might want to set the Label's WordWrap property to True so that it will
extend for multiple lines instead of being truncated by the right border of the control. Alternatively, you might
decide to set the AutoSize property to True and let the control automatically resize itself to accommodate longer
caption strings.
You sometimes need to modify the default value of a Label's BackStyle property. Label controls usually cover
what's already on the form's surface (other lightweight controls, output from graphic methods, and so on)
because their background is considered to be opaque. If you want to show a character string somewhere on the
form but at the same time you don't want to obscure underlying objects, set the BackStyle property to 0-
Transparent.
2) TextBox
TextBox controls offer a natural way for users to enter a value in your program. For this reason, they tend to be
the most frequently used controls in the majority of Windows applications. TextBox controls, which have a
great many properties and events, are also among the most complex intrinsic controls.
Setting properties to a TextBox
Text can be entered into the text box by assigning the necessary string to the text property of the control
If the user needs to display multiple lines of text in a TextBox, set the MultiLine property to True
To customize the scroll bar combination on a TextBox, set the ScrollBars property.
Scroll bars will always appear on the TextBox when it's MultiLine property is set to True and its
ScrollBars property is set to anything except None(0)
If you set the MultilIne property to True, you can set the alignment using the Alignment property. The
test is left-justified by default. If the MultiLine property is et to False, then setting the Alignment property
has no effect.
Run-Time Properties of a TextBox control
The Text property is the one you'll reference most often in code, and conveniently it's the default property for
the TextBox control. Three other frequently used properties are these:
The SelStart property sets or returns the position of the blinking caret (the insertion point where the
text you type appears). Note that the blinking cursor inside TextBox and other controls is named caret, to
distinguish it from the cursor (which is implicitly the mouse cursor). When the caret is at the beginning of the
contents of the TextBox control, SelStart returns 0; when it's at the end of the string typed by the user, SelStart
returns the value Len(Text). You can modify the SelStart property to programmatically move the caret.
The SelLength property returns the number of characters in the portion of text that has been
highlighted by the user, or it returns 0 if there's no highlighted text. You can assign a nonzero value to this
property to programmatically select text from code. Interestingly, you can assign to this property a value
larger than the current text's length without raising a run-time error.
The SelText property sets or returns the portion of the text that's currently selected, or it returns an
empty string if no text is highlighted. Use it to directly retrieve the highlighted text without having to query
Text, SelStart, and SelLength properties. What's even more interesting is that you can assign a new value to
this property, thus replacing the current selection with your own. If no text is currently selected, your string is
simply inserted at the current caret position.
The following Figure summarizes the common TextBox control's properties and methods.
Property/
Method Description
Properties
Enabled specifies whether user can interact with this control or not
Index Specifies the control array index
Locked If this control is set to True user can use it else if this control is set to false the control
cannot be used
MaxLength Specifies the maximum number of characters to be input. Default value is set to 0 that
means user can input any number of characters
MousePointer Using this we can set the shape of the mouse pointer when over a TextBox
Multiline By setting this property to True user can have more than one line in the TextBox
PasswordChar This is to specify mask character to be displayed in the TextBox
ScrollBars
This to set either the vertical scrollbars or horizontal scrollbars to make appear in the
TextBox. User can also set it to both vertical and horizontal. This property is used with the
Multiline property.
Text Specifies the text to be displayed in the TextBox at runtime
ToolTipIndex This is used to display what text is displayed or in the control
Visible By setting this user can make the Textbox control visible or invisible at runtime
Methods
SetFocus Transfers focus to the TextBox
3) PictureBox Control
PictureBox controls are among the most powerful and complex items in the Visual Basic Toolbox window. In a
sense, these controls are more similar to forms than to other controls. For example, PictureBox controls support
all the properties related to graphic output, including AutoRedraw, ClipControls, HasDC, FontTransparent,
CurrentX, CurrentY, and all the Draw, Fill, and Scale properties. PictureBox controls also support all graphic
methods, such as Cls, PSet, Point, Line, and Circle and conversion methods, such as ScaleX, ScaleY,
TextWidth, and TextHeight.
Loading images
Once you place a PictureBox on a form, you might want to load an image in it, which you do by setting the
Picture property in the Properties window. You can load images in many different graphic formats, including
bitmaps (BMP), device independent bitmaps (DIB), metafiles (WMF), enhanced metafiles (EMF), GIF and
JPEG compressed files, and icons (ICO and CUR). You can decide whether a control should display a border,
resetting the BorderStyle to 0-None if necessary. Another property that comes handy in this phase is AutoSize:
Set it to True and let the control automatically resize itself to fit the assigned image.
You might want to set the Align property of a PictureBox control to something other than the 0-None value. By
doing that, you attach the control to one of the four form borders and have Visual Basic automatically move and
resize the PictureBox control when the form is resized. PictureBox controls expose a Resize event, so you can
trap it if you need to move and resize its child controls too. You can do more interesting things at run time. To
begin with, you can programmatically load any image in the control using the LoadPicture function:
Picture1.Picture = LoadPicture("c:\windows\setup.bmp")
4) Frame Controls
Frame controls are similar to Label controls in that they can serve as captions for those controls that don't have
their own. Moreover, Frame controls can also (and often do) behave as containers and host other controls. In
most cases, you only need to drop a Frame control on a form and set its Caption property. If you want to create
a borderless frame, you can set its BorderStyle property to 0-None.
Controls that are contained in the Frame control are said to be child controls. Moving a control at design time
over a Frame control—or over any other container, for that matter—doesn't automatically make that control a
child of the Frame control. After you create a Frame control, you can create a child control by selecting the
child control's icon in the Toolbox and drawing a new instance inside the Frame's border. Alternatively, to make
an existing control a child of a Frame control, you must select the control, press Ctrl+X to cut it to the
Clipboard, select the Frame control, and press Ctrl+V to paste the control inside the Frame. If you don't follow
this procedure and you simply move the control over the Frame, the two controls remain completely
independent of each other, even if the other control appears in front of the Frame control.
Frame controls, like all container controls, have two interesting features. If you move a Frame control, all the
child controls go with it. If you make a container control disabled or invisible, all its child controls also become
disabled or invisible. You can exploit these features to quickly change the state of a group of related controls.
5) Command Control
Using Command Button controls is trivial. In most cases, you just draw the control on the form's surface, set its
Caption property to a suitable string (adding an & character to associate a hot key with the control if you so
choose), and you're finished, at least with user-interface issues. To make the button functional, you write code
in its Click event procedure, as in this fragment:
Private Sub Command1_Click()
' Save data, then unload the current form.
Call SaveDataToDisk
Unload Me
End Sub
You can use two other properties at design time to modify the behavior of a Command Button control. You can
set the Default property to True if it's the default push button for the form (the button that receives a click when
the user presses the Enter key—usually the OK or Save button). Similarly, you can set the Cancel property to
True if you want to associate the button with the Escape key.
The only relevant Command Button's run-time property is Value, which sets or returns the state of the control
(True if pressed, False otherwise). Value is also the default property for this type of control. In most cases, you
don't need to query this property because if you're inside a button's Click event you can be sure that the button is
being activated. The Value property is useful only for programmatically clicking a button:
This fires the button's Click event.
Command1.Value = True
Properties of a CommandButton control
To display text on a CommandButton control, set its Caption property.
An event can be activated by clicking on the CommandButton.
To set the background colour of the CommandButton, select a colour in the BackColor property.
To set the text color set the Forecolor property.
Font for the CommandButton control can be selected using the Font property.
To enable or disable the buttons set the Enabled property to True or False
To make visible or invisible the buttons at run time, set the Visible property to True or False.
Tooltips can be added to a button by setting a text to the Tooltip property of the CommandButton.
6) OptionButton
OptionButton controls are also known as radio buttons because of their shape. You always use OptionButton
controls in a group of two or more because their purpose is to offer a number of mutually exclusive choices.
Anytime you click on a button in the group, it switches to a selected state and all the other controls in the group
become unselected.
Preliminary operations for an OptionButton control are similar to those already described for CheckBox
controls. You set an OptionButton control's Caption property to a meaningful string, and if you want you can
change its Alignment property to make the control right aligned. If the control is the one in its group that's in the
selected state, you also set its Valueproperty to True. (The OptionButton's Value property is a Boolean value
because only two states are possible.) Value is the default property for this control.
In the following example, the shape control is placed in the form together with 3 Option Boxes. When the user
clicks on different option boxes, different shapes will appear. The values of the shape control are 0, 1, and 2
which will make it appear as a rectangle, a square, an oval shape, respectively.
Private Sub Option1_Click ( )
Shape1.Shape = 0
End Sub
Private Sub Option2_Click()
Shape1.Shape = 1
End Sub
Private Sub Option3_Click()
Shape1.Shape = 2
End Sub
7) Check Box Control
The CheckBox control is similar to the option button, except that a list of choices can be made using check
boxes where you cannot choose more than one selection using an OptionButton. By ticking theCheckBox the
value is set to True. This control can also be grayed when the state of the CheckBox is unavailable, but you
must manage that state through code.
When you place a CheckBox control on a form, all you have to do, usually, is set its Caption property to a
descriptive string. You might sometimes want to move the little check box to the right of its caption, which you
do by setting the Alignment property to 1-Right Justify, but in most cases the default setting is OK. If you want
to display the control in a checked state, you set its Value property to 1-Checked right in the Properties window,
and you set a grayed state with 2-Grayed.
The only important event for CheckBox controls is the Click event, which fires when either the user or the code
changes the state of the control. In many cases, you don't need to write code to handle this event. Instead, you
just query the control's Value property when your code needs to process user choices. You usually write code in
a CheckBox control's Click event when it affects the state of other controls.
Example
Private Sub Command1_Click()
If Check1.Value = 1 And Check2.Value = 0 Then
MsgBox "Apple is selected"
ElseIf Check2.Value = 1 And Check1.Value = 0 Then
MsgBox "Orange is selected"
Else
MsgBox "All are selected"
End If
End Sub
8) Combo Box
ComboBox controls present a set of choices that are displayed vertically in a column. If the number of items
exceed the value that be displayed, scroll bars will automatically appear on the control. These scroll bars can be
scrolled up and down or left to right through the list.
The following Fig lists some of the common ComboBox properties and methods.
Property/Method Description
Properties
Enabled By setting this property to True or False user can decide whether user can interact
with this control or not
Index Specifies the Control array index
List String array. Contains the strings displayed in the drop-down list. Starting array
index is 0.
ListCount Integer. Contains the number of drop-down list items
ListIndex Integer. Contains the index of the selected ComboBox item. If an item is not
selected, ListIndex is -1
Locked Boolean. Specifies whether user can type or not in the ComboBox
MousePointer Integer. Specifies the shape of the mouse pointer when over the area of the
ComboBox
NewIndex Integer. Index of the last item added to the ComboBox. If the ComboBox does not
contain any items , NewIndex is -1
Sorted Boolean. Specifies whether the ComboBox's items are sorted or not.
Style Integer. Specifies the style of the ComboBox's appearance
TabStop Boolean. Specifies whether ComboBox receives the focus or not.
Text String. Specifies the selected item in the ComboBox
ToolTipIndex String. Specifies what text is displayed as the ComboBox's tool tip
Visible Boolean. Specifies whether ComboBox is visible or not at run time
Methods
AddItem Add an item to the ComboBox
Clear Removes all items from the ComboBox
RemoveItem Removes the specified item from the ComboBox
SetFocus Transfers focus to the ComboBox
9) List Box
The function of the List Box is to present a list of items where the user can click and select the items from the
list. In order to add items to the list, we can use the AddItem method. For example, if you wish to add a
number of items to list box 1, you can key in the following statements
Example
Private Sub Form_Load ( )
List1.AddItem “Lesson1”
List1.AddItem “Lesson2”
List1.AddItem “Lesson3”
List1.AddItem “Lesson4”
End Sub
The items in the list box can be identified by the ListIndex property, the value of the ListIndex for the first item
is 0, the second item has a ListIndex 1, and the second item has a ListIndex 2 and so on
The following common ListBox properties and methods are same as Combobox Properties & methods..
10) Drive List Box
The Drive ListBox is for displaying a list of drives available in your computer. When you place this control into
the form and run the program, you will be able to select different drives from your computer.
Using these controls, user can traverse the host computer's file system; locate any folder or files on any hard
disk, even on network drives. The files are controls are independent of one another, and each can exist on it's
own, but they are rarely used separately. In a nutshell, the DriveListBox control is a combo box-like control
that's automatically filled with your drive's letters and volume labels.
11) Directory List Box
The Directory List Box is for displaying the list of directories or folders in a selected drive. When you place this
control into the form and run the program, you will be able to select different directories from a selected drive
in your computer. The DirListBox is a special list box that displays a directory tree. When the user selects a
path in the DirListBox control, the FileListBox control is filled with the list of files in that directory.
12) FileList Box
The File List Box is for displaying the list of files in a selected directory or folder. When you place this control
into the form and run the program, you will be able to shown the list of files in a selected directory.
The FileListBox control, on the other hand, exposes one property that you can set at design time—the Pattern
property. This property indicates which files are to be shown in the list area: Its default value is *.* (all files),
but you can enter whatever specification you need, and you can also enter multiple specifications using the
semicolon as a separator.
13) Horizontal Scrollbar
The Scroll Bar is a commonly used control, which enables the user to select a value by positioning it at the
desired location. It represents a set of values. The Min and Max property represents the minimum and
maximum value. The value property of the Scroll Bar represents its current value that may be any integer
between minimum and maximum values assigned.
The Horizontal Scrollbar controls are perfectly identical, apart from their different orientation. After you place
an instance of such a control on a form, you have to worry about only a few properties: Min and Max represent
the valid range of values, SmallChange is the variation in value you get when clicking on the scroll bar's arrows,
and LargeChange is the variation you get when you click on either side of the scroll bar indicator. The default
initial value for those two properties is 1, but you'll probably have to change LargeChange to a higher value. For
example, if you have a scroll bar that lets you browse a portion of text, SmallChange should be 1 (you scroll
one line at a time) and LargeChange should be set to match the number of visible text lines in the window.
14) Vertical Scrollbar
The Vertical Scroll Bar is a commonly used control, which enables the user to select a value by positioning it at
the desired location. It represents a set of values. The Min and Max property represents the minimum and
maximum value. The value property of the Scroll Bar represents its current value that may be any integer
between minimum and maximum values assigned.
The Vertical Scrollbar controls are perfectly identical, apart from their different orientation. After you place an
instance of such a control on a form, you have to worry about only a few properties: Min and Max represent the
valid range of values, SmallChange is the variation in value you get when clicking on the scroll bar's arrows,
and LargeChange is the variation you get when you click on either side of the scroll bar indicator. When a
scrollbar control has the focus, you can move the indicator using the Left, Right, Up, Down, PgUp, PgDn,
Home, and End keys.
15) Timer
A Timer control is invisible at run time, and its purpose is to send a periodic pulse to the current application.
You can trap this pulse by writing code in the Timer's Timer event procedure and take advantage of it to execute
a task in the background or to monitor a user's actions. This control exposes only two meaningful properties:
Interval and Enabled. Interval stands for the number of milliseconds between subsequent pulses (Timer events),
while Enabled lets you activate or deactivate events. When you place the Timer control on a form, its Interval is
0, which means no events.
16) Shape Control
In a sense, the Shape control is an extension of the Line control. It can display six basic shapes: Rectangle,
Square, Oval, Circle, Rounded Rectangle, and Rounded Square. It supports all the Line control's properties and
a few more: BorderStyle (0-Transparent, 1-Solid), FillColor, and FillStyle (the same as a form's properties with
the same names). The same performance considerations I pointed out for the Line control apply to the Shape
control.
17) Line Control
The Line control is a decorative control whose only purpose is let you draw one or more straight lines at design
time, instead of displaying them using a Line graphical method at run time. This control exposes a few
properties whose meaning should sound familiar to you by now: BorderColor (the color of the line),
BorderStyle (the same as a form's DrawStyle property), BorderWidth (the same as a form's DrawWidth
property), and DrawMode. While the Line control is handy, remember that using a Line method at run time is
usually better in terms of performance.
18) Image Control
Image controls are far less complex than PictureBox controls. They don't support graphical methods or the
AutoRedraw and the ClipControls properties, and they can't work as containers, just to hint at their biggest
limitations. Nevertheless, you should always strive to use Image controls instead of PictureBox controls because
they load faster and consume less memory and system resources. Remember that Image controls are
windowless objects that are actually managed by Visual Basic without creating a Windows object. Image
controls can load bitmaps and JPEG and GIF images.
When you're working with an Image control, you typically load a bitmap into its Picture property either at
design time or at run time using the LoadPicture function. Image controls don't expose the AutoSize property
because by default they resize to display the contained image (as it happens with PictureBox controls set at
AutoSize = True). On the other hand, Image controls support a Stretch property that, if True, resizes the image
(distorting it if necessary) to fit the control. In fact, you can zoom in to or reduce an image by loading it in an
Image control and then setting its Stretch property to True to change its width and height.
Label controls to provide a descriptive caption and possibly an associated hot key for other controls, such as
TextBox, ListBox, and ComboBox, that don't expose the Caption property. In most cases, you just place a Label
control where you need it, set its Caption property to a suitable string (embedding an ampersand character in
front of the hot key you want to assign), and you're done. Caption is the default property for Label controls.
Other useful properties are BorderStyle(if you want the Label control to appear inside a 3D border) and
Alignment (if you want to align the caption to the right or center it on the control). In most cases, the alignment
depends on how the Label control relates to its companion control: for example, if the Label control is placed to
the left of its companion field, you might want to set its Alignment property to 1-Right Justify. The value 2-
Center is especially useful for stand-alone Label controls.
You can insert a literal & character in a Label control's Caption property by doubling it. For example, to see
Research & Development you have to type &Research && Development. Note that if you have multiple but
isolated &s, the one that selects the hot key is the last one and all others are ignored. This tip applies to all the
controls that expose a Caption property. (The & has no special meaning in forms' Caption properties, however.)
If the caption string is a long one, you might want to set the Label's WordWrap property to True so that it will
extend for multiple lines instead of being truncated by the right border of the control. Alternatively, you might
decide to set the AutoSize property to True and let the control automatically resize itself to accommodate longer
caption strings.
You sometimes need to modify the default value of a Label's BackStyle property. Label controls usually cover
what's already on the form's surface (other lightweight controls, output from graphic methods, and so on)
because their background is considered to be opaque. If you want to show a character string somewhere on the
form but at the same time you don't want to obscure underlying objects, set the BackStyle property to 0-
Transparent.
2) TextBox
TextBox controls offer a natural way for users to enter a value in your program. For this reason, they tend to be
the most frequently used controls in the majority of Windows applications. TextBox controls, which have a
great many properties and events, are also among the most complex intrinsic controls.
Setting properties to a TextBox
Text can be entered into the text box by assigning the necessary string to the text property of the control
If the user needs to display multiple lines of text in a TextBox, set the MultiLine property to True
To customize the scroll bar combination on a TextBox, set the ScrollBars property.
Scroll bars will always appear on the TextBox when it's MultiLine property is set to True and its
ScrollBars property is set to anything except None(0)
If you set the MultilIne property to True, you can set the alignment using the Alignment property. The
test is left-justified by default. If the MultiLine property is et to False, then setting the Alignment property
has no effect.
Run-Time Properties of a TextBox control
The Text property is the one you'll reference most often in code, and conveniently it's the default property for
the TextBox control. Three other frequently used properties are these:
The SelStart property sets or returns the position of the blinking caret (the insertion point where the
text you type appears). Note that the blinking cursor inside TextBox and other controls is named caret, to
distinguish it from the cursor (which is implicitly the mouse cursor). When the caret is at the beginning of the
contents of the TextBox control, SelStart returns 0; when it's at the end of the string typed by the user, SelStart
returns the value Len(Text). You can modify the SelStart property to programmatically move the caret.
The SelLength property returns the number of characters in the portion of text that has been
highlighted by the user, or it returns 0 if there's no highlighted text. You can assign a nonzero value to this
property to programmatically select text from code. Interestingly, you can assign to this property a value
larger than the current text's length without raising a run-time error.
The SelText property sets or returns the portion of the text that's currently selected, or it returns an
empty string if no text is highlighted. Use it to directly retrieve the highlighted text without having to query
Text, SelStart, and SelLength properties. What's even more interesting is that you can assign a new value to
this property, thus replacing the current selection with your own. If no text is currently selected, your string is
simply inserted at the current caret position.
The following Figure summarizes the common TextBox control's properties and methods.
Property/
Method Description
Properties
Enabled specifies whether user can interact with this control or not
Index Specifies the control array index
Locked If this control is set to True user can use it else if this control is set to false the control
cannot be used
MaxLength Specifies the maximum number of characters to be input. Default value is set to 0 that
means user can input any number of characters
MousePointer Using this we can set the shape of the mouse pointer when over a TextBox
Multiline By setting this property to True user can have more than one line in the TextBox
PasswordChar This is to specify mask character to be displayed in the TextBox
ScrollBars
This to set either the vertical scrollbars or horizontal scrollbars to make appear in the
TextBox. User can also set it to both vertical and horizontal. This property is used with the
Multiline property.
Text Specifies the text to be displayed in the TextBox at runtime
ToolTipIndex This is used to display what text is displayed or in the control
Visible By setting this user can make the Textbox control visible or invisible at runtime
Methods
SetFocus Transfers focus to the TextBox
3) PictureBox Control
PictureBox controls are among the most powerful and complex items in the Visual Basic Toolbox window. In a
sense, these controls are more similar to forms than to other controls. For example, PictureBox controls support
all the properties related to graphic output, including AutoRedraw, ClipControls, HasDC, FontTransparent,
CurrentX, CurrentY, and all the Draw, Fill, and Scale properties. PictureBox controls also support all graphic
methods, such as Cls, PSet, Point, Line, and Circle and conversion methods, such as ScaleX, ScaleY,
TextWidth, and TextHeight.
Loading images
Once you place a PictureBox on a form, you might want to load an image in it, which you do by setting the
Picture property in the Properties window. You can load images in many different graphic formats, including
bitmaps (BMP), device independent bitmaps (DIB), metafiles (WMF), enhanced metafiles (EMF), GIF and
JPEG compressed files, and icons (ICO and CUR). You can decide whether a control should display a border,
resetting the BorderStyle to 0-None if necessary. Another property that comes handy in this phase is AutoSize:
Set it to True and let the control automatically resize itself to fit the assigned image.
You might want to set the Align property of a PictureBox control to something other than the 0-None value. By
doing that, you attach the control to one of the four form borders and have Visual Basic automatically move and
resize the PictureBox control when the form is resized. PictureBox controls expose a Resize event, so you can
trap it if you need to move and resize its child controls too. You can do more interesting things at run time. To
begin with, you can programmatically load any image in the control using the LoadPicture function:
Picture1.Picture = LoadPicture("c:\windows\setup.bmp")
4) Frame Controls
Frame controls are similar to Label controls in that they can serve as captions for those controls that don't have
their own. Moreover, Frame controls can also (and often do) behave as containers and host other controls. In
most cases, you only need to drop a Frame control on a form and set its Caption property. If you want to create
a borderless frame, you can set its BorderStyle property to 0-None.
Controls that are contained in the Frame control are said to be child controls. Moving a control at design time
over a Frame control—or over any other container, for that matter—doesn't automatically make that control a
child of the Frame control. After you create a Frame control, you can create a child control by selecting the
child control's icon in the Toolbox and drawing a new instance inside the Frame's border. Alternatively, to make
an existing control a child of a Frame control, you must select the control, press Ctrl+X to cut it to the
Clipboard, select the Frame control, and press Ctrl+V to paste the control inside the Frame. If you don't follow
this procedure and you simply move the control over the Frame, the two controls remain completely
independent of each other, even if the other control appears in front of the Frame control.
Frame controls, like all container controls, have two interesting features. If you move a Frame control, all the
child controls go with it. If you make a container control disabled or invisible, all its child controls also become
disabled or invisible. You can exploit these features to quickly change the state of a group of related controls.
5) Command Control
Using Command Button controls is trivial. In most cases, you just draw the control on the form's surface, set its
Caption property to a suitable string (adding an & character to associate a hot key with the control if you so
choose), and you're finished, at least with user-interface issues. To make the button functional, you write code
in its Click event procedure, as in this fragment:
Private Sub Command1_Click()
' Save data, then unload the current form.
Call SaveDataToDisk
Unload Me
End Sub
You can use two other properties at design time to modify the behavior of a Command Button control. You can
set the Default property to True if it's the default push button for the form (the button that receives a click when
the user presses the Enter key—usually the OK or Save button). Similarly, you can set the Cancel property to
True if you want to associate the button with the Escape key.
The only relevant Command Button's run-time property is Value, which sets or returns the state of the control
(True if pressed, False otherwise). Value is also the default property for this type of control. In most cases, you
don't need to query this property because if you're inside a button's Click event you can be sure that the button is
being activated. The Value property is useful only for programmatically clicking a button:
This fires the button's Click event.
Command1.Value = True
Properties of a CommandButton control
To display text on a CommandButton control, set its Caption property.
An event can be activated by clicking on the CommandButton.
To set the background colour of the CommandButton, select a colour in the BackColor property.
To set the text color set the Forecolor property.
Font for the CommandButton control can be selected using the Font property.
To enable or disable the buttons set the Enabled property to True or False
To make visible or invisible the buttons at run time, set the Visible property to True or False.
Tooltips can be added to a button by setting a text to the Tooltip property of the CommandButton.
6) OptionButton
OptionButton controls are also known as radio buttons because of their shape. You always use OptionButton
controls in a group of two or more because their purpose is to offer a number of mutually exclusive choices.
Anytime you click on a button in the group, it switches to a selected state and all the other controls in the group
become unselected.
Preliminary operations for an OptionButton control are similar to those already described for CheckBox
controls. You set an OptionButton control's Caption property to a meaningful string, and if you want you can
change its Alignment property to make the control right aligned. If the control is the one in its group that's in the
selected state, you also set its Valueproperty to True. (The OptionButton's Value property is a Boolean value
because only two states are possible.) Value is the default property for this control.
In the following example, the shape control is placed in the form together with 3 Option Boxes. When the user
clicks on different option boxes, different shapes will appear. The values of the shape control are 0, 1, and 2
which will make it appear as a rectangle, a square, an oval shape, respectively.
Private Sub Option1_Click ( )
Shape1.Shape = 0
End Sub
Private Sub Option2_Click()
Shape1.Shape = 1
End Sub
Private Sub Option3_Click()
Shape1.Shape = 2
End Sub
7) Check Box Control
The CheckBox control is similar to the option button, except that a list of choices can be made using check
boxes where you cannot choose more than one selection using an OptionButton. By ticking theCheckBox the
value is set to True. This control can also be grayed when the state of the CheckBox is unavailable, but you
must manage that state through code.
When you place a CheckBox control on a form, all you have to do, usually, is set its Caption property to a
descriptive string. You might sometimes want to move the little check box to the right of its caption, which you
do by setting the Alignment property to 1-Right Justify, but in most cases the default setting is OK. If you want
to display the control in a checked state, you set its Value property to 1-Checked right in the Properties window,
and you set a grayed state with 2-Grayed.
The only important event for CheckBox controls is the Click event, which fires when either the user or the code
changes the state of the control. In many cases, you don't need to write code to handle this event. Instead, you
just query the control's Value property when your code needs to process user choices. You usually write code in
a CheckBox control's Click event when it affects the state of other controls.
Example
Private Sub Command1_Click()
If Check1.Value = 1 And Check2.Value = 0 Then
MsgBox "Apple is selected"
ElseIf Check2.Value = 1 And Check1.Value = 0 Then
MsgBox "Orange is selected"
Else
MsgBox "All are selected"
End If
End Sub
8) Combo Box
ComboBox controls present a set of choices that are displayed vertically in a column. If the number of items
exceed the value that be displayed, scroll bars will automatically appear on the control. These scroll bars can be
scrolled up and down or left to right through the list.
The following Fig lists some of the common ComboBox properties and methods.
Property/Method Description
Properties
Enabled By setting this property to True or False user can decide whether user can interact
with this control or not
Index Specifies the Control array index
List String array. Contains the strings displayed in the drop-down list. Starting array
index is 0.
ListCount Integer. Contains the number of drop-down list items
ListIndex Integer. Contains the index of the selected ComboBox item. If an item is not
selected, ListIndex is -1
Locked Boolean. Specifies whether user can type or not in the ComboBox
MousePointer Integer. Specifies the shape of the mouse pointer when over the area of the
ComboBox
NewIndex Integer. Index of the last item added to the ComboBox. If the ComboBox does not
contain any items , NewIndex is -1
Sorted Boolean. Specifies whether the ComboBox's items are sorted or not.
Style Integer. Specifies the style of the ComboBox's appearance
TabStop Boolean. Specifies whether ComboBox receives the focus or not.
Text String. Specifies the selected item in the ComboBox
ToolTipIndex String. Specifies what text is displayed as the ComboBox's tool tip
Visible Boolean. Specifies whether ComboBox is visible or not at run time
Methods
AddItem Add an item to the ComboBox
Clear Removes all items from the ComboBox
RemoveItem Removes the specified item from the ComboBox
SetFocus Transfers focus to the ComboBox
9) List Box
The function of the List Box is to present a list of items where the user can click and select the items from the
list. In order to add items to the list, we can use the AddItem method. For example, if you wish to add a
number of items to list box 1, you can key in the following statements
Example
Private Sub Form_Load ( )
List1.AddItem “Lesson1”
List1.AddItem “Lesson2”
List1.AddItem “Lesson3”
List1.AddItem “Lesson4”
End Sub
The items in the list box can be identified by the ListIndex property, the value of the ListIndex for the first item
is 0, the second item has a ListIndex 1, and the second item has a ListIndex 2 and so on
The following common ListBox properties and methods are same as Combobox Properties & methods..
10) Drive List Box
The Drive ListBox is for displaying a list of drives available in your computer. When you place this control into
the form and run the program, you will be able to select different drives from your computer.
Using these controls, user can traverse the host computer's file system; locate any folder or files on any hard
disk, even on network drives. The files are controls are independent of one another, and each can exist on it's
own, but they are rarely used separately. In a nutshell, the DriveListBox control is a combo box-like control
that's automatically filled with your drive's letters and volume labels.
11) Directory List Box
The Directory List Box is for displaying the list of directories or folders in a selected drive. When you place this
control into the form and run the program, you will be able to select different directories from a selected drive
in your computer. The DirListBox is a special list box that displays a directory tree. When the user selects a
path in the DirListBox control, the FileListBox control is filled with the list of files in that directory.
12) FileList Box
The File List Box is for displaying the list of files in a selected directory or folder. When you place this control
into the form and run the program, you will be able to shown the list of files in a selected directory.
The FileListBox control, on the other hand, exposes one property that you can set at design time—the Pattern
property. This property indicates which files are to be shown in the list area: Its default value is *.* (all files),
but you can enter whatever specification you need, and you can also enter multiple specifications using the
semicolon as a separator.
13) Horizontal Scrollbar
The Scroll Bar is a commonly used control, which enables the user to select a value by positioning it at the
desired location. It represents a set of values. The Min and Max property represents the minimum and
maximum value. The value property of the Scroll Bar represents its current value that may be any integer
between minimum and maximum values assigned.
The Horizontal Scrollbar controls are perfectly identical, apart from their different orientation. After you place
an instance of such a control on a form, you have to worry about only a few properties: Min and Max represent
the valid range of values, SmallChange is the variation in value you get when clicking on the scroll bar's arrows,
and LargeChange is the variation you get when you click on either side of the scroll bar indicator. The default
initial value for those two properties is 1, but you'll probably have to change LargeChange to a higher value. For
example, if you have a scroll bar that lets you browse a portion of text, SmallChange should be 1 (you scroll
one line at a time) and LargeChange should be set to match the number of visible text lines in the window.
14) Vertical Scrollbar
The Vertical Scroll Bar is a commonly used control, which enables the user to select a value by positioning it at
the desired location. It represents a set of values. The Min and Max property represents the minimum and
maximum value. The value property of the Scroll Bar represents its current value that may be any integer
between minimum and maximum values assigned.
The Vertical Scrollbar controls are perfectly identical, apart from their different orientation. After you place an
instance of such a control on a form, you have to worry about only a few properties: Min and Max represent the
valid range of values, SmallChange is the variation in value you get when clicking on the scroll bar's arrows,
and LargeChange is the variation you get when you click on either side of the scroll bar indicator. When a
scrollbar control has the focus, you can move the indicator using the Left, Right, Up, Down, PgUp, PgDn,
Home, and End keys.
15) Timer
A Timer control is invisible at run time, and its purpose is to send a periodic pulse to the current application.
You can trap this pulse by writing code in the Timer's Timer event procedure and take advantage of it to execute
a task in the background or to monitor a user's actions. This control exposes only two meaningful properties:
Interval and Enabled. Interval stands for the number of milliseconds between subsequent pulses (Timer events),
while Enabled lets you activate or deactivate events. When you place the Timer control on a form, its Interval is
0, which means no events.
16) Shape Control
In a sense, the Shape control is an extension of the Line control. It can display six basic shapes: Rectangle,
Square, Oval, Circle, Rounded Rectangle, and Rounded Square. It supports all the Line control's properties and
a few more: BorderStyle (0-Transparent, 1-Solid), FillColor, and FillStyle (the same as a form's properties with
the same names). The same performance considerations I pointed out for the Line control apply to the Shape
control.
17) Line Control
The Line control is a decorative control whose only purpose is let you draw one or more straight lines at design
time, instead of displaying them using a Line graphical method at run time. This control exposes a few
properties whose meaning should sound familiar to you by now: BorderColor (the color of the line),
BorderStyle (the same as a form's DrawStyle property), BorderWidth (the same as a form's DrawWidth
property), and DrawMode. While the Line control is handy, remember that using a Line method at run time is
usually better in terms of performance.
18) Image Control
Image controls are far less complex than PictureBox controls. They don't support graphical methods or the
AutoRedraw and the ClipControls properties, and they can't work as containers, just to hint at their biggest
limitations. Nevertheless, you should always strive to use Image controls instead of PictureBox controls because
they load faster and consume less memory and system resources. Remember that Image controls are
windowless objects that are actually managed by Visual Basic without creating a Windows object. Image
controls can load bitmaps and JPEG and GIF images.
When you're working with an Image control, you typically load a bitmap into its Picture property either at
design time or at run time using the LoadPicture function. Image controls don't expose the AutoSize property
because by default they resize to display the contained image (as it happens with PictureBox controls set at
AutoSize = True). On the other hand, Image controls support a Stretch property that, if True, resizes the image
(distorting it if necessary) to fit the control. In fact, you can zoom in to or reduce an image by loading it in an
Image control and then setting its Stretch property to True to change its width and height.
Common properties of VB controls
Name The string value used to refer to the control in code.
Caption The text that is displayed in the label
Text The string of text that is to be displayed in the control.
ForeColor Specifies the color of text or graphics to be displayed in the control.
BackColor Specifies the background color of the control.
Font For controls displaying text, specifies the font (name, style, size, etc.) to be applied to the
displayed text.
Picture Specifies the graphic to be displayed in the control.
Visible Specifies whether the control is visible or hidden.
Enabled Determines whether or not the control can respond to user-generated events.
Width Specifies the width of the control in pixels.
Height Specifies the height of the control in pixels.
Caption The text that is displayed in the label
Text The string of text that is to be displayed in the control.
ForeColor Specifies the color of text or graphics to be displayed in the control.
BackColor Specifies the background color of the control.
Font For controls displaying text, specifies the font (name, style, size, etc.) to be applied to the
displayed text.
Picture Specifies the graphic to be displayed in the control.
Visible Specifies whether the control is visible or hidden.
Enabled Determines whether or not the control can respond to user-generated events.
Width Specifies the width of the control in pixels.
Height Specifies the height of the control in pixels.
Event Driven Programming
Visual Basic programs are built around events. Events are various things that can happen in a program. this will
become clearer when studied in contrast to procedural programming. In procedural languages, an application is
written is executed by checking for the program logically through the program statements, one after another.
For a temporary phase, the control may be transferred to some other point in a program. While in an event
driven application, the program statements are executed only when a particular event calls a specific part of the
code that is assigned to the event.
Let us consider a TextBox control and a few of its associated events to understand the concept of event driven
programming. The TextBox control supports various events such as Change, Click, MouseMove and many
more that will be listed in the Properties dropdown list in the code window for the TextBox control. We will
look into a few of them as given below.
The code entered in the Change event fires when there is a change in the contents of the TextBox
The Click event fires when the TextBox control is clicked.
The MouseMove event fires when the mouse is moved over the TextBox
As explained above, several events are associated with different controls and forms, some of the events being
common to most of them and few being specific to each control.
become clearer when studied in contrast to procedural programming. In procedural languages, an application is
written is executed by checking for the program logically through the program statements, one after another.
For a temporary phase, the control may be transferred to some other point in a program. While in an event
driven application, the program statements are executed only when a particular event calls a specific part of the
code that is assigned to the event.
Let us consider a TextBox control and a few of its associated events to understand the concept of event driven
programming. The TextBox control supports various events such as Change, Click, MouseMove and many
more that will be listed in the Properties dropdown list in the code window for the TextBox control. We will
look into a few of them as given below.
The code entered in the Change event fires when there is a change in the contents of the TextBox
The Click event fires when the TextBox control is clicked.
The MouseMove event fires when the mouse is moved over the TextBox
As explained above, several events are associated with different controls and forms, some of the events being
common to most of them and few being specific to each control.
The Control Properties in vb6
Before writing an event procedure for the control to response to a user's input,
you have to set certain properties for the control to determine its appearance
and how it will work with the event procedure. You can set the properties of the
controls in the properties window or at runtime.
In properties form1 Figure on the right is a typical properties window for a
form. You can rename the form caption to any name that you like best. In the
properties window, the item appears at the top part is the object currently
selected (in Figure, the object selected is Form1). At the bottom part, the items
listed in the left column represent the names of various properties associated
with the selected object while the items listed in the right column represent the
states of the properties. Properties can be set by highlighting the items in the
right column then change them by typing or selecting the options available.
For example, in order to change the caption, just highlight Form1 under the
name Caption and change it to other names. You may also try to alter the
appearance of the form by setting it to 3D or flat. Other things you can do are to
change its foreground and background color, change the font type and font size,
enable or disable minimize and maximize buttons and etc.
You can also change the properties at runtime to give special effects such
as change of color, shape, animation effect and so on. For example the
following code will change the form color to red every time the form is loaded.
VB uses hexadecimal system to represent the color. You can check the color
codes in the properties windows which are showed up under ForeColor and
BackColor .
Private Sub Form_Load()
Form1.Show
Form1.BackColor = &H000000FF&
End Sub
What are methods and properties?
All the controls in VB except the Pointer are objects in Visual Basic. These objects have associated with
properties and methods. Real world objects are loaded with properties. For example, a flower is loaded certain
color, shape and fragrance. Similarly programming objects are loaded with properties. A property is a named
attribute of a programming object. Properties define the characteristics of an object such as Size, Color etc. or
sometimes the way in which it behaves. For example, a TextBox accepts properties such as Enabled, Font,
MultiLine, Text, Visible, Width, etc.
The properties that are discussed above are design-time properties that can be set at the design time by selecting
the Properties Window. But certain properties cannot be set at design time. For example, the CurrentX and
CurrentY properties of a Form cannot be set at the design time.
A method is an action that can be performed on objects. For example, a cat is an object. Its properties might
include long white hair, blue eyes, 3 pounds weight etc. A complete definition of cat must only encompass on
its looks, but should also include a complete itemization of its activities. Therefore, a cat's methods might be
move, jump, play, breath etc.
Similarly in object-oriented programming, a method is a connected or built-in procedure, a block of code that
can be invoked to impart some action on a particular object. A method requires an object to provide them with a
context. For example, the word Move has no meaning in Visual Basic, but the statement,
Text1.Move 700, 400
performs a very precise action. The TextBox control has other associated methods such as Refresh, SetFocus,
etc.
you have to set certain properties for the control to determine its appearance
and how it will work with the event procedure. You can set the properties of the
controls in the properties window or at runtime.
In properties form1 Figure on the right is a typical properties window for a
form. You can rename the form caption to any name that you like best. In the
properties window, the item appears at the top part is the object currently
selected (in Figure, the object selected is Form1). At the bottom part, the items
listed in the left column represent the names of various properties associated
with the selected object while the items listed in the right column represent the
states of the properties. Properties can be set by highlighting the items in the
right column then change them by typing or selecting the options available.
For example, in order to change the caption, just highlight Form1 under the
name Caption and change it to other names. You may also try to alter the
appearance of the form by setting it to 3D or flat. Other things you can do are to
change its foreground and background color, change the font type and font size,
enable or disable minimize and maximize buttons and etc.
You can also change the properties at runtime to give special effects such
as change of color, shape, animation effect and so on. For example the
following code will change the form color to red every time the form is loaded.
VB uses hexadecimal system to represent the color. You can check the color
codes in the properties windows which are showed up under ForeColor and
BackColor .
Private Sub Form_Load()
Form1.Show
Form1.BackColor = &H000000FF&
End Sub
What are methods and properties?
All the controls in VB except the Pointer are objects in Visual Basic. These objects have associated with
properties and methods. Real world objects are loaded with properties. For example, a flower is loaded certain
color, shape and fragrance. Similarly programming objects are loaded with properties. A property is a named
attribute of a programming object. Properties define the characteristics of an object such as Size, Color etc. or
sometimes the way in which it behaves. For example, a TextBox accepts properties such as Enabled, Font,
MultiLine, Text, Visible, Width, etc.
The properties that are discussed above are design-time properties that can be set at the design time by selecting
the Properties Window. But certain properties cannot be set at design time. For example, the CurrentX and
CurrentY properties of a Form cannot be set at the design time.
A method is an action that can be performed on objects. For example, a cat is an object. Its properties might
include long white hair, blue eyes, 3 pounds weight etc. A complete definition of cat must only encompass on
its looks, but should also include a complete itemization of its activities. Therefore, a cat's methods might be
move, jump, play, breath etc.
Similarly in object-oriented programming, a method is a connected or built-in procedure, a block of code that
can be invoked to impart some action on a particular object. A method requires an object to provide them with a
context. For example, the word Move has no meaning in Visual Basic, but the statement,
Text1.Move 700, 400
performs a very precise action. The TextBox control has other associated methods such as Refresh, SetFocus,
etc.
The project explorer window
The Project explorer window gives you a tree-structured view of all the files inserted into the application. You
can expand these and collapse branches of the views to get more or less detail (Project explorer). The project
explorer window displays forms, modules or other separators which are supported by the visual basic like
classes and Advanced Modules. If you want to select a form on its own simply double click on the project
explorer window for a more detailed look. And it will display it where the Default form is located.
Properties Window
The Properties Window is docked under the Project Explorer window. The Properties Window exposes the various
characteristics of selected objects. Each and every form in an application is considered an object. Now, each object in
Visual Basic has characteristics such as color and size. Other characteristics affect not just the appearance of the object
but the way it behaves too. All these characteristics of an object are called its properties. Thus, a form has properties and
any controls placed on it will have properties too. All of these properties are displayed in the Properties Window.
The Default Layout or Form Layout Window
When we start Visual Basic, we are provided with a VB project. A VB project is a collection of the following
modules and files.
The global module( that contains declaration and procedures)
The form module(that contains the graphic elements of the VB application along with the instruction )
The general module (that generally contains general-purpose instructions not pertaining to anything
graphic on-screen)
The class module(that contains the defining characteristics of a class, including its properties and
methods)
The resource files(that allows you to collect all of the texts and bitmaps for an application in one place)
On start up, Visual Basic will displays the following windows:
The Blank Form window
The Project window
The Properties window
It also includes a Toolbox that consists of all the controls essential for developing a VB Application. Controls
are tools such as boxes, buttons, labels and other objects draw on a form to get input or display output. They
also add visual appeal.
Tool box
You may have noticed that when you click on different controls the Properties Window changes slightly this is
due to different controls having different functions. Therefore more options are needed for example if you had a
picture then you want to show an image. But if you wanted to open a internet connection you would have to fill
in the remote host and other such settings. When you use the command ( ) you will find that a new set of
properties come up the following will provide a description and a property.
What an event is
The ‘look’ of a Visual Basic application is determined by what controls are used, but the ‘feel’ is determined by
the events. An event is something which can happen to a control. For example, a user can click on a button,
change a text box, or resize a form. As explained in Creating a Visual Basic Application, writing a program is
made up of three events: 1) select suitable controls, 2) set the properties, and 3) write the code. It is at the code
writing stage when it becomes important to choose appropriate events for each control. To do this double click
on the control the event will be used for, or click on the icon in the project window (usually top right of
screen). A code window should now be displayed similar to the one shown below.
The left hand dropdown box provides a list of all controls used by the current form, the form itself, and a special
section called General Declarations. The corresponding dropdown box on the right displays a list of all events
applicable to the current control (as specified by the left hand dropdown box). Events displayed in bold signify
that code has already been written for them, unbold events are unused. To demonstrate that different events can
play a significant role in determining the feel of an application, a small example program will be written to add
two numbers together and display the answer. The first solution to this problem will use the click event of a
command button, while the second will the change event of two text boxes.
Click Event
Before any events can be coded it is necessary to design the interface from suitable controls. As shown in the
screen shot below use: 2 text boxes to enter the numbers, a label for the ‘+’ sign, a command button for the ‘=’
sign, and another label for the answer.
Making the click event is very simple just select the button with the mouse and double click visual basic will
generate
You can see on the top right there is a 'click' dropdown list this is known as a event handler.
can expand these and collapse branches of the views to get more or less detail (Project explorer). The project
explorer window displays forms, modules or other separators which are supported by the visual basic like
classes and Advanced Modules. If you want to select a form on its own simply double click on the project
explorer window for a more detailed look. And it will display it where the Default form is located.
Properties Window
The Properties Window is docked under the Project Explorer window. The Properties Window exposes the various
characteristics of selected objects. Each and every form in an application is considered an object. Now, each object in
Visual Basic has characteristics such as color and size. Other characteristics affect not just the appearance of the object
but the way it behaves too. All these characteristics of an object are called its properties. Thus, a form has properties and
any controls placed on it will have properties too. All of these properties are displayed in the Properties Window.
The Default Layout or Form Layout Window
When we start Visual Basic, we are provided with a VB project. A VB project is a collection of the following
modules and files.
The global module( that contains declaration and procedures)
The form module(that contains the graphic elements of the VB application along with the instruction )
The general module (that generally contains general-purpose instructions not pertaining to anything
graphic on-screen)
The class module(that contains the defining characteristics of a class, including its properties and
methods)
The resource files(that allows you to collect all of the texts and bitmaps for an application in one place)
On start up, Visual Basic will displays the following windows:
The Blank Form window
The Project window
The Properties window
It also includes a Toolbox that consists of all the controls essential for developing a VB Application. Controls
are tools such as boxes, buttons, labels and other objects draw on a form to get input or display output. They
also add visual appeal.
Tool box
You may have noticed that when you click on different controls the Properties Window changes slightly this is
due to different controls having different functions. Therefore more options are needed for example if you had a
picture then you want to show an image. But if you wanted to open a internet connection you would have to fill
in the remote host and other such settings. When you use the command ( ) you will find that a new set of
properties come up the following will provide a description and a property.
What an event is
The ‘look’ of a Visual Basic application is determined by what controls are used, but the ‘feel’ is determined by
the events. An event is something which can happen to a control. For example, a user can click on a button,
change a text box, or resize a form. As explained in Creating a Visual Basic Application, writing a program is
made up of three events: 1) select suitable controls, 2) set the properties, and 3) write the code. It is at the code
writing stage when it becomes important to choose appropriate events for each control. To do this double click
on the control the event will be used for, or click on the icon in the project window (usually top right of
screen). A code window should now be displayed similar to the one shown below.
The left hand dropdown box provides a list of all controls used by the current form, the form itself, and a special
section called General Declarations. The corresponding dropdown box on the right displays a list of all events
applicable to the current control (as specified by the left hand dropdown box). Events displayed in bold signify
that code has already been written for them, unbold events are unused. To demonstrate that different events can
play a significant role in determining the feel of an application, a small example program will be written to add
two numbers together and display the answer. The first solution to this problem will use the click event of a
command button, while the second will the change event of two text boxes.
Click Event
Before any events can be coded it is necessary to design the interface from suitable controls. As shown in the
screen shot below use: 2 text boxes to enter the numbers, a label for the ‘+’ sign, a command button for the ‘=’
sign, and another label for the answer.
Making the click event is very simple just select the button with the mouse and double click visual basic will
generate
You can see on the top right there is a 'click' dropdown list this is known as a event handler.
The Development Environment or Form Window
Learning the ins and outs of the Development Environment before you learn visual basic is somewhat like
learning for a test you must know where all the functions belong and what their purpose is. First we will start
with labeling the development environment.
The above diagram shows the development environment with all the important points labeled. Many of Visual
basic functions work similar to Microsoft word e.g. the Tool Bar and the tool box is similar to other products
on the market which work off a single click then drag the width of the object required. The Tool Box contains
the control you placed on the form window. All of the controls that appear on the Tool Box controls on the
above picture never runs out of controls as soon as you place one on the form another awaits you on the Tool
Box ready to be placed as needed.
learning for a test you must know where all the functions belong and what their purpose is. First we will start
with labeling the development environment.
The above diagram shows the development environment with all the important points labeled. Many of Visual
basic functions work similar to Microsoft word e.g. the Tool Bar and the tool box is similar to other products
on the market which work off a single click then drag the width of the object required. The Tool Box contains
the control you placed on the form window. All of the controls that appear on the Tool Box controls on the
above picture never runs out of controls as soon as you place one on the form another awaits you on the Tool
Box ready to be placed as needed.
The Visual Basic 6 Integrated Development Environment
Before you can program in VB 6, you need to install Visual Basic 6 in your computer.
On start up, Visual Basic 6.0 will display the following dialog box as shown in figure 1.1. You can choose to
start a new project, open an existing project or select a list of recently opened programs. A project is a collection
of files that make up your application. There are various types of applications that we could create; however, we
shall concentrate on creating Standard EXE programs (EXE means executable program). Now, click on the
Standard EXE icon to go into the actual Visual Basic 6 programming environment.
You can choose to start a new project, open an existing project or select a list of recently opened programs. A
project is a collection of files that make up your application. There are various types of applications that we
could create; however, we shall concentrate on creating Standard EXE programs (EXE means executable
program). Now, click on the Standard EXE icon to go into the actual Visual Basic 6 programming
environment.
In this section, we will not go into the technical aspects of Visual Basic programming yet, what you need to do
is just try out the examples below to see how does in VB program look like.
On start up, Visual Basic 6.0 will display the following dialog box as shown in figure 1.1. You can choose to
start a new project, open an existing project or select a list of recently opened programs. A project is a collection
of files that make up your application. There are various types of applications that we could create; however, we
shall concentrate on creating Standard EXE programs (EXE means executable program). Now, click on the
Standard EXE icon to go into the actual Visual Basic 6 programming environment.
You can choose to start a new project, open an existing project or select a list of recently opened programs. A
project is a collection of files that make up your application. There are various types of applications that we
could create; however, we shall concentrate on creating Standard EXE programs (EXE means executable
program). Now, click on the Standard EXE icon to go into the actual Visual Basic 6 programming
environment.
In this section, we will not go into the technical aspects of Visual Basic programming yet, what you need to do
is just try out the examples below to see how does in VB program look like.
What is GUI?
A GUI (usually pronounced GOO-ee) is a graphical (rather than purely textual) user interface to a computer.
As you read this, you are looking at the GUI or graphical user interface of your particular Web browser. The
term came into existence because the first interactive user interfaces to computers were not graphical; they were
text-and-keyboard oriented and usually consisted of commands you had to remember and computer responses
that were infamously brief. The command interface of the DOS operating system (which you can still get to
from your Windows operating system) is an example of the typical user-computer interface before GUIs
arrived. An intermediate step in user interfaces between the command line interface and the GUI was the nongraphical
menu-based interface, which let you interact by using a mouse rather than by having to type in
keyboard commands.
As you read this, you are looking at the GUI or graphical user interface of your particular Web browser. The
term came into existence because the first interactive user interfaces to computers were not graphical; they were
text-and-keyboard oriented and usually consisted of commands you had to remember and computer responses
that were infamously brief. The command interface of the DOS operating system (which you can still get to
from your Windows operating system) is an example of the typical user-computer interface before GUIs
arrived. An intermediate step in user interfaces between the command line interface and the GUI was the nongraphical
menu-based interface, which let you interact by using a mouse rather than by having to type in
keyboard commands.
What programs can you create with Visual Basic 6?
With VB 6, you can create any program depending on your objective. For example, if you are a college or
university lecturer, you can create educational programs to teach business, economics, engineering, computer
science, accountancy, financial management, information system and more to make teaching more effective and
interesting. If you are in business, you can also create business programs such as inventory management system,
point-of-sale system, payroll system, financial program as well as accounting program to help manage your
business and increase productivity. For those of you who like games and working as games programmer, you
can create those programs as well. Indeed, there is no limit to what program you can create! There are many
such programs in this tutorial, so you must spend more time on the tutorial in order to learn how to create those
programs.
university lecturer, you can create educational programs to teach business, economics, engineering, computer
science, accountancy, financial management, information system and more to make teaching more effective and
interesting. If you are in business, you can also create business programs such as inventory management system,
point-of-sale system, payroll system, financial program as well as accounting program to help manage your
business and increase productivity. For those of you who like games and working as games programmer, you
can create those programs as well. Indeed, there is no limit to what program you can create! There are many
such programs in this tutorial, so you must spend more time on the tutorial in order to learn how to create those
programs.
Features of Visual Basic 6.0
Features:-- Visual Basic was designed to be easily learned and used by beginner programmers. The language
not only allows programmers to create simple GUI applications, but can also develop complex applications.
Programming in VB is a combination of visually arranging components or controls on a form, specifying
attributes and actions of those components, and writing additional lines of code for more functionality. Since
default attributes and actions are defined for the components, a simple program can be created without the
programmer having to write many lines of code. Performance problems were experienced by earlier versions,
but with faster computers and native code compilation this has become less of an issue.
Forms are created using drag-and-drop techniques. A tool is used to place controls (e.g., text boxes, buttons,
etc.) on the form (window). Controls have attributes and event handlers associated with them. Default values
are provided when the control is created, but may be changed by the programmer. Many attribute values can be
modified during run time based on user actions or changes in the environment, providing a dynamic application
The Visual Basic compiler is shared with other Visual Studio languages (C, C++), but restrictions in the IDE do
not allow the creation of some targets (Windows model DLLs) and threading models.
not only allows programmers to create simple GUI applications, but can also develop complex applications.
Programming in VB is a combination of visually arranging components or controls on a form, specifying
attributes and actions of those components, and writing additional lines of code for more functionality. Since
default attributes and actions are defined for the components, a simple program can be created without the
programmer having to write many lines of code. Performance problems were experienced by earlier versions,
but with faster computers and native code compilation this has become less of an issue.
Forms are created using drag-and-drop techniques. A tool is used to place controls (e.g., text boxes, buttons,
etc.) on the form (window). Controls have attributes and event handlers associated with them. Default values
are provided when the control is created, but may be changed by the programmer. Many attribute values can be
modified during run time based on user actions or changes in the environment, providing a dynamic application
The Visual Basic compiler is shared with other Visual Studio languages (C, C++), but restrictions in the IDE do
not allow the creation of some targets (Windows model DLLs) and threading models.
What is a Database?
·
A database is a collection of information. This information is stored in a very
structured manner. By exploiting this
known structure, we can access and modify the information quickly and
correctly.
·
In this information age,
databases are everywhere:
Þ
When you go to the library and
look up a book on their computer, you are accessing the library’s book database.
Þ
When you go on-line and
purchase some product, you are accessing the web merchant’s product database.
Þ
Your friendly bank keeps all
your financial records on their database. When you receive your monthly statement, the
bank generates a database report.
Þ
When you call to make a doctor
appointment, the receptionist looks into their database for available times.
Þ
When you go to your car dealer
for repairs, the technician calls up your past work record on the garage database.
Þ
At the grocery store, when the
checker scans each product, the price is found in the store’s database, where inventory control is
also performed.
Þ
When you are watching a
baseball game on television and the announcer tells you that “the batter is
hitting .328 against left-handed pitchers whose mother was born in Kentucky on
a Tuesday morning,” that useless information is pulled from the team’s database.
·
You can surely think of many
more places that databases enter your life.
The idea is that they are everywhere.
And, each database requires some way for a user to interact with the
information within. Such interaction is
performed by a database management system (DBMS).
·
The tasks of a DBMS are really quite simple. In concept, there are only a few things you
can do with a database:
- View the data
- Find some data of interest
- Modify the data
- Add some data
- Delete some data
There are many
commercial database management systems that perform these tasks. Programs like Access (a Microsoft product)
and Oracle are used world-wide. In this
course, we look at using Visual Basic as a DBMS.
·
Examples where you might use
Visual Basic as a DBMS:
Þ
Implementing a new application
that requires management of a database
Þ
Connecting to an existing
database
Þ
Interacting with a database via
the internet
·
In a DBMS, the database may be
available locally on your (or the
user’s) computer, available on a LAN
(local area network) shared by multiple users, or only available on a web server via the Internet. In
this course, we spend most of our time looking at local databases, but access
with remote databases is addressed.
·
We will look at databases in
more depth in the next chapter. You will
see that databases have their own vocabulary.
Now, let’s take a look at how Visual Basic fits into the database
management system.
Saturday, 18 August 2018
Friday, 17 August 2018
DATABASE SECURITY:
Security is an important issue in database management because information stored in a database is a very valuable and many a time, very sensitive commodity. So the data in a database should be protected from unauthorized access and updates. If you are using a single user database and you are the only user, then the whole issue of data security boils down to keeping your machine secure from other users. But the commercial DBMSs are rarely single user. Many people and applications will be concurrently accessing it to get information, many users and programs will be updating the information, and yet another group of people will be deleting information that has become obsolete or incorrect.
Database security involves allowing or disallowing users from performing actions on the database and the objects within it. A privilege is permission to access a named object in a prescribed manner; for example: Permission to query a table.
DATABASE ENVIRONMENT:
Database security is the protection of the database against intentional and unintentional threats. Database security is the business of the entire organization as all people use the data held in the organization's database and any loss corruption to the data would affect the day-to-day operation of the organization and the performance of the people. Therefore, database security encompasses hardware, software, infrastructure, people and data of the organization. Now there is greater emphasis on database security than in the past as the amount of data stored in corporate database is increasing and people are depending more on the corporate data for decision-making, customer service management, supply chain management and so on. Any loss or unavailability to the corporate data will cripple today's organization and will seriously affect its performance. Now the unavailability of the database for even a few minutes could result in serious losses to the organization
DATA SECURITY RISKS
A threat is any situation, event or personnel that will adversely affect the database and the smooth and efficient functioning of the organization. The harm may be tangible, such as loss of data, damage to hardware or software or intangible such as loss of customer goodwill or credibility and so on.
The integrity and privacy of data are at risk from unauthorized users, external sources listening in on the network, and internal users giving away the store.
- Data Tampering
Privacy of communications is essential to ensure that data cannot be modified or viewed in transit. Distributed environments bring with them the possibility that a malicious third party perpetrate a computer crime by tampering with data as it moves between sites. In modification attack, an unauthorized party on the network intercepts data in transit and parts of that data before retransmitting it.
- Eavesdropping and Data Theft
Data must be stored and transmitted securely, so that information such as credit numbers cannot be stolen. Over the Internet and in Wide Area Network (WAN) environments, both public carriers and private network owners often route portions of their network through insecure landlines, extremely vulnerable microwave and satellite links, or a number of servers. This situation leaves valuable data open to view by any interested party. In Local Area Network (LAN) environments within a building or campus, insiders with access to the physical wiring can potentially view data not intended for them.
- Falsifying User Identities
In a distributed environment, it becomes more feasible for a user to falsify an identity to gain access to sensitive and important information. A transaction that should go from the Personnel system on Server A to the Pay system on Server B could be intercepted in transit and routed instead to a terminal pretending as Server B.
- Password-Related Threats
Users typically respond to the problem of managing multiple passwords in several ways:
They may select easy-to-guess passwords-such as a name, fictional character, or a Word found in a dictionary. All of these passwords are vulnerable to dictionary attacks.
They may also choose to standardize passwords so that they are the same on all machines or web sites.
They can also use passwords with slight viria|ion{ |hit(cin(bm ma{ily(dmrived from known passwords.
Users with complex passwords may write them down where an attacker can easily find them, or they may just forget them-requiring costly administration and support efforts.
- Unauthorized Access to Tables and Columns
The database may contain confidential tables, or confidential columns in a table, which should not be available indiscriminately to all users authorized to access the database. It should be possible to protect data on a column level.
- Unauthorized Access to Data Rows
Certain data rows may contain confidential information that should not be available indiscriminately to users authorized to access the table. For example, in a shared environment businesses should have access only to their own data; customers should be able to see only their own orders. Systems must therefore be flexible and should be able to support different security policies depending on whether you are dealing with customers or employees. For example, you may require stronger authentication for employees (who can see more data) than you do for customers. Or, you may allow employees to see all customer records while customers can only see their own records.
- Lack of Accountability
If the system administrator is unable to track users' activities, then users cannot be held responsible for their actions. There must be some reliable way (such as audit trails) to monitor who is performing what operations on the data.
- Complex User Management Requirements
Systems must often support thousands-or hundreds of thousands-of users and therefore they must be scalable. In such large-scale environments, the burden of managing user accounts and passwords makes your system vulnerable to error and attack. You need to know who the user really is-across all tiers of the application-to have reliable security. Administration of thousands, or hundreds of thousands of users, is difficult enough on a single system. This burden is compounded when security must be administered on multiple systems. To meet the challenges of scale in security administration, you should be able to centrally manage users and privileges across multiple applications and databases, using a directory based on industry standards. This can reduce system management costs and increase business efficiency.
- DIMENSIONS OF DATABASE SECURITY
To protect all the elements of complex computing systems, you must address security issues in many dimensions.
- Hardware or Physical Infrastructure - The hardware could be damaged due to a number of reasons from power surges to fire or other natural calamities or due to sabotage by antisocial elements. Your computers and other equipment must be physically inaccessible to unauthorized users. The equipment could be damaged due to electronic interference or radiation. This means that you must keep them in a secure physical environment.
- DBMS and Application Software - The DBMS could be damaged by unauthorized personnel. They could corrupt or delete the data in the databases. The application programs could be altered or damaged. The programs and data could be stolen and could be used against you. This could happen if the security mechanism is not good enough or if it fails and gives access to unauthorized people.
- Personnel - There are a number of people who interact with the DBMS and the databases-database administrators, security officers, network administrators, application administrators, application developers, other users, etc. All these people could do damage to the system if they want. The DBAs and security officers could give database access to the wrong people or if they are not good the security countermeasures and policies they design and implement might not be good enough to prevent an attack on the database. Application programmers could create trapdoors in their programs, which could be used for gaining unauthorized entry to the database. They could make program alterations and develop programs that are not secure. Users could give away their user IDs and passwords either intentionally or unintentionally. They could access, view and copy confidential data. So the people, especially the people responsible for system administration and data security at your site must be reliable. You may need to perform background checks on DBAs before making hiring decisions.
- Procedural - The procedures used in the operation of your system must assure reliable data. For example, one person might be responsible for database backups. Her only role is to be sure the database is up and running. Another person might be responsible for generating application reports involving payroll or sales data. His role is to examine the data and verify its integrity. It may be wise to separate out users' functional roles in data management. There should be sound security policies and efficient people to implement it.
- Technical – Storage, access, manipulation, and transmission of data must be safeguarded by technology that enforces your particular information control policies.
DATA SECURITY REQUIREMENTS
We should use technology to ensure a secure computing environment for the organization. Although it is not possible to find a technological solution for all problems, most of the security issues could be resolved using appropriate technology.
Confidentiality
A secure system ensures the confidentiality of data. This means that it allows individuals to see only the data that they are supposed to see.
Privacy of Communications
The DBMS should be capable of controlling the spread of confidential personal Information such as health, employment, and credit records. It should also keep the corporate data such as trade secrets, proprietary information about products and processes, competitive analyses, as well as marketing and sales plans secure and away from the unauthorized people.
Secure Storage of Sensitive Data
Once confidential data has been entered, its integrity and privacy must be protected on the databases and servers wherein it resides.
Authenticated Users
Authentication is a way of implementing decisions about whom to trust. Authentication methods seek to guarantee the identity of system users: that a person is who he says he is, and not an impostor.
Granular Access Control
How much data should a particular user see? Access control is the ability to hide portions of the database, so that access to the data does not become an all-or-nothing proposition. A clerk in the HR department might need some access to the EMPLOYEE table-but he should not be permitted to access salary information for the entire company! The granularity of access control is the degree to which data access can be differentiated for particular tables, views, rows, and columns of a database.
Note the distinction between authentication, authorization, and access control. Authentication is the process by which a user's identity is checked. When a user is authenticated, he is verified as an authorized user of an application. Authorization is the process by which the user's privileges are ascertained. Access control is the process by which the user's access to physical data in the application is limited, based on his privileges.
Integrity
A secure system ensures that the data it contains is valid. Data integrity means that data is protected from deletion and corruption, both while it resides within the database, and while it is being transmitted over the network.
Availability
A secure system makes data available to authorized users, without delay. Denial-of-service attacks are attempts to block authorized users' ability to access and use the system when needed.
Database Administrators
The DBA is a special user who is created when the system is installed. DBA is a person (or persons) who is responsible for the management of the database. The DBA is responsible for the maintenance and smooth functioning of the system. Usually DBAs have all the powers that the system can give on all database objects and for all commands. He can pass most of these powers-the ones that he wishes-to other users of the system.
After the DBA, the next sets of users who have most powers on a database object (tables, views, etc.) are its owners. In many systems the user who creates a database object is its owner. A table owner or a view owner is usually given full privileges for the object that he owns. Like DBA, the owner of a database object can grant his power to other users. Users other than the special users mentioned above need explicit permission to perform any operation on a database object. These permissions are given using the GRANT command and taken away using the REVOKE command.
Each database requires at least one database administrator (DBA) to administer it. Because a database management system can be large and can have many users, often this is not a one person job. In such cases, there is a group of DBAs who share responsibility. A database administrator's responsibilities can include the following tasks:
Installing and upgrading the DBMS and application tools
Allocating system storage and planning future storage requirements for the database system
Enrolling users and maintaining system security
Controlling and monitoring user access to the database
Monitoring and optimizing the performance of the database (Performance tuning)
Planning for backup and recovery of database information
Backing up and restoring the database
Security Officers
In some cases, an organization assigns one or more security officers to a database. A security officer enrolls users, controls and monitors user access to the database, and maintains system security. If a company does not have a separate security officer, then the above duties are performed by the DBA.
Subscribe to:
Comments (Atom)