B.SC - IT 12-01 Visual Basic Q1. Difference Between Procedure and The Function in Visual Basic?
B.SC - IT 12-01 Visual Basic Q1. Difference Between Procedure and The Function in Visual Basic?
IT 12-01
Visual Basic
FUNCTION:-
-1- P.T.O
Syntax:-
-2- P.T.O
The greatest advantage of using a MDI form is that in an
MDI application, the menus for each child are displayed on the
MDI form rather than on the child form them selves. And if the
child with the focus does not have a menu, the MDI form’s menu
is displayed.
Thus in an MDI form the menu’s are created once and they
can be used with any child form on focus thus it saves time as
there is no need to create separate menus for each form.
The MDI application uses several sets of menus depending on the
type of document.
A MDI application provides a common workspace for all the child
windows.
The menu control of the MDI form or MDI child form can be
used to display the list of open child forms by setting the window
list property for that menu control to true
We can use the arrange method to rearrange the child
forms in the MDI form. The child forms can be displayed as
cascading or horizontally tiled in the lower portion of the MDI
form.
Label: The label control displays a text a user cannot interact with and
modify.
Frame: The frame control provides a visual and functional container for
controls.
ComboBox: The combo box control combines a text with a list box. Allows a
user to type in selection or select an item from a drop-down list.
-3- P.T.O
ListBox: The list box control displays a list of items that user can choose
from.
HScrollBar and VScrollBar: The horizontal scroll bar and vertical scroll bar
allow an user to select a value within a range of values.
Timer: The timer control executes timer events at specified interval of times.
DirListBox: The drive list box control displays and allows a user to select
directories and paths.
DriveListBox: The drive list box control displays and allows a user to select
valid disk drives.
FilelistBox: The drive list box control displays and allows a user to select
from a list of files.
Shape: The shape control adds a rectangle, square ellipses or circle to a form.
OLE: The OLE container control embeds data into a Visual Basic
application.
-4- P.T.O
programs but also with Vc++, Borland C++ or any other
language that supports OCX Active x control . It is based on the
old technology known as OLE extended with technology to
support Internet
The active X components are:-
Active x control
Active x code – EXE or DLL
Active x Document – EXE or DLL
Common dialog
Data Bound Combo Box
Apex Data Bound Grid
Data Bound List Box
Microsoft Flex Grid
STEPS:-
-5- P.T.O
Select project -> properties and in the properties dialog box type
the project name and description
Project name: user control1
Project Description: control to print the name
Then save the file (The file will be saved with extension .CTL)
Active X Document:-
-6- P.T.O
---------------------------------------End Of Section
01-----------------------------------
-7- P.T.O
Section 02
If…Then:-
We can use either single line syntax or multiple line block syntax.
If…Then…Else:-
If<condition1> then
{statement block 1}
else if<condition2> then
{statement block2}
else
{
statement block n
}
end if
Example:-
Dim marks as integer
Marks=val(text1.text)
If marks>90 then
Text2.text=”good”
Else if
Marks>70 then
Text2.text=”satisfactory”
Else
Text2.text=”labour hard”
-8- P.T.O
End if
Syntax:- Do while<condition>
Statement
Loop
Example: dim k as integer
K=5
Do while k<10
Text1.text=k
K=k+1
-9- P.T.O
Loop structure-Do..loop while:
Syntax:- Do
Statement
Loop while<condition>
Example:-
- 10 -
P.T.O
Loop structure -- For Each….Next:- The loop structure is
used to repeat a group of statements each element in an array or
collection.
Example:-Dim ctrl as control
Dim ctr as integer
For each ctrl in form 1
If type of ctrl is text box then
Ctr=ctr+1
End if
Next
Msgbox(“Total no. of text boxes=”&ctr);
Q2. what are data files ? How do you create it and how do
you make use of it explain?
- 11 -
P.T.O
Open <File Name> for append as #<File number>
- 12 -
P.T.O
(a)Opening random file :- Open statement is used to open
an existing random file or to create a new random file. Syntax
:-
- 13 -
P.T.O
How can we use binary file
- 14 -
P.T.O
export the report to HTML or text files. The Data Report Designer
has
several functions:-
1. Drag and drop functionality for fields.
2. Toolbox controls
3. Print preview
4. Print reports
5. File export
6. Export templates
7. Asynchronous operation.
Property Setting
Connection student
Then click ok to close the dialog box and save the project. Once
the Data Environment Designer has been created, you can create
a data report. To do so select the data report designer in the
- 15 -
P.T.O
project explorer window and set the properties of the data report
object according to the table below.
Property Setting
Name rptstud
Caption student data report
On the properties window, click the data source and then click
data environment1
Properties Setting
Name cmdshow
Data report1.show
End sub
- 16 -
P.T.O
Click the show Report Button to display the Report in print
preview mode.
SYSTEM FUNCTIONS:-
String functions:-
1) String functions:-
e.g.
Mystring=”hello”&spaces(10)&”world”
- 17 -
P.T.O
Right : Returns a specified no. of characters from the right
side of the string
Syntax:- right (stringlength)
e.g
a=”hello Dev”
b=right(a,c)
‘returns “ev”
Syntax:- Rtrim(string)
Ltrim(string)
Trim(string)
e.g
mystring=” dev ”
a=Ltrim(mystring)
‘result “dev ”
e.g:
x-val(“29”)
‘returns x=29
Syntax:- now
Example:-
Today = now
‘assigns the current system data & time.
Syntax: time
- 18 -
P.T.O
Eg.
Today’s time= time
Connect
Database name
Exclusive
Read only property
Record source
- 19 -
P.T.O
It provides the following programming advantages:-
DBENGINE
WORKSPACE
DATABASE
TABLEDEF
FIELDS
INDEX AND
RECORDSET OBJECTS
RDO(Remote Data Objects):-
In order to access external data source like oracle, SQL server etc
we must create an ODBC data source. The ODBC databases are
created to help VB link the specified database in VB project.
The RDO is used to read and update data stored in Relational
database Management System (RDBMS) that are external to VB and
MS Jet Data Engine. RDO has methods and properties that are better
suited to work with Remote database.
- 20 -
P.T.O
1. Active X Data Control.
2. Active X Connection.
3. Active X Records.
It works just like the Data control and DAO. It can be added
easily into the project by selecting project then components and
then Ms-ADO Data Control 6.0 (OLEDB) from the list.
4. To display the data from the table, add text fields on to the form.
To display the data from stdmast text boxes are added to the
form. You must now bind the indivudual date bound controls to
the data control, and then specify which field in the table each of
the control will display
- 21 -
P.T.O
DATA FIELD ST_CLASS
At the design time, set the data source property of the bound
control to a data control. data field property can be set at
designed time or run time.
6) SAVE the project and run it (F5). Use the Arrow key of the data
control to scroll through the records of stdmast
Q5. How do you create Active x Documents? Explain?
On the file menu, click new project to open new project dialog
box. Double click on the active x document exe icon visual basic
automatically adds a user document designer to the project. If
the designer is not immediately visible right click over its default
name, user document 1, in the project explorer window, click new
object. When the designer appears its default name is visible in
the title bar.
In the properties window change the name of the user document
1 to first doc
In the project explorer window, double click the first doc icon to
bring it to the front
Place a command button on the form designer
- 22 -
P.T.O
NAME PROPERTY VALUE
CAPTION
In order to view the first doc document, you must run the ACTIVE
X Doc project. It will load the container, Internet explorer in which
the document will be loaded.
-----------------------------------End Of Section
02-----------------------------------
THE END
- 23 -
P.T.O