Visual Basic Assignment = MI 08 – 01
Q1. What is the significance of the procedure and the function in VB. ?
A1. Procedures :
1. Procedure allow us to break programs into discrete logical units each of which can be debugged more easily than an entire program without procedures.
2. Procedures used in one program can act as building blocks for other programs, usually with little or no modification. There are several type of procedures in VB.
A procedure can be a Sub, Function or Property procedure.
sub procedures do not return value
function procedures return a value
property procedures can return and assign values and set references to objects
Functions :
Visual Basic Includes system-provided, or intrinsic function, like Sqr, Cos, Chr. In addition we can use the function statement to write our own function procedures.
Like a sub procedure a function procedure is a separate procedure that can take arguments, perform a series of statements, and change the value of its arguments. The arguments for a function procedure work in exactly the same way as the arguments for a sub procedure. Aside from the function keyword, there are three differences between sub and function procedures.
Generally we call a function by including the function procedure name and arguments in the right side of the larger statement or expression.
function procedures have data types just as variables do. This determines the type of the return value. (in the absence of an as clause, the type is the default variant type.)
we return a value by assigning it to the procedure name itself. When the function procedure returns a value, this value can then become part of a larger expression.
Q2. What is OLE? Why do you use this in VB? Explain.
A2. OLE is the abbreviation for object linking and embedding. A program that includes OLE capabilities can communicate data (text and graphics) to other window applications that are OLE based.
Adding the OLE control to a Form.
To add the OLE control to a form, double click on the OLE – icon in the toolbox. Visual Basic responds by placing the OLE control in the form and displaying the insert object dialog box. The insert object dialog box displays a list of objects that can be embedded in a program.
select the item bitmap image from the list of objects, then click on OK.
save the project.
run the project.
Double click on the OLE control on the form and the object to which it has been linked will be executed. Paintbrush will be executed in our example.
Adding the OLE control to a Form to run a power point presentation.
1. Add the OLE control to a form, double click on the OLE – icon in the toolbox. Visual basic responds by placing the OLE control in the form and displaying the insert object dialog box.
2. Select power point presentation and indicate the power point presentation file.
3. Save and run the project.
Q3. Discuss the use of Multiple Document Interface application.
A3. The multiple document interface(MDI) allows you to create an application that maintains multiple forms within a single container form. Applications such as Microsoft excel and work for windows have multiple-document interfaces.
An MDI application allows the user to display multiple documents at the same time, with each document displayed in its own window. Document windows are contained in a parent window, which provides a workspace for all the document windows in the application.
Your application can have only one MDI form, which contains all the applications child forms. At runtime, child forms are displayed within the internal area of the MDI form (the area inside the form’s borders and below any caption and menu bars). When a child form is minimized its icon appears on the MDI form instead on the desktop. Any application can also include standard, non-MDI forms that are not contained in the MDI from. A typical use of a standard form in an MDI application is to display a modal dialog box.
Q4. Explain the objects available in VB to access the database.
A4. Jet Database
Database created by using the jet database engine. Microsoft access also uses the jet database engine as its data manager component.
ODBC databases (open data base connectivity)
Open data base connectivity (ODBC) provides a universal database connectivity application programming interface (API) that enables applications to access data in a wide range of proprietary databases. Based on the X/Open SQL Access Group’s Call Level Interface (CLI) specification, ODBC is an open vendor – neutral way to uniformly access data stored in different formats and database engines. ODBC is the most widely used interface to relational data. As the standard interface to relational data, your application can access a lot of data using ODBC. ODBC databases include Microsoft SQL Server, Sybase, Oracle etc.
ISAM databases (Indexed Sequential Access Method)
ISAM databases include FoxPro, Microsoft visual FoxPro, Paradox etc.
Data in the following databases can be accessed in visual basic using the following options.
Data Control: Uses the Jet Database engine to retrieve data from jet databases (like MS-ACCESS) and ISAM databases like FoxPro, Paradox etc.
DAO – Data Access Objects: Uses the Jet Database engine to retrieve data from jet databases (like MS-ACCESS) and ISAM databases like FoxPro, Paradox etc.
RDO – Remote Data Object: Remote Data objects and collections provide a framework for using code to create and manipulate components of a remote ODBC database system. The RDO is only supported on 32-bit operating system such as Windows 95 and Windows NT. To use the Remote Data Objects, you must set a reference to the Microsoft Remote Data Objects 2.0 object library in the visual basic references dialog box.
ADO –ActiveX Data Object: ADO is designed as an easy-to-use application level interface to Microsoft’s newest and most powerful data access paradigm, OLE DB. OLE DB provides high-performance access to any data source, including relational and non-relational databases, email and file systems, text and graphics, custom business objects etc.
ODBC API: API stands for Application Program Interface, which is a collection of low-level functions, which can be called directly from within a visual basic application. ODBC also supports a set of API functions, which can be called to connect to a database.
Q5. What are ActiveX Components? How do you create ActiveX controls? Explain.
A5. ActiveX is based on an old technology known as OLE (Object Linking and Embedding) extended with technology to support Internet. The possible components of this technology are:
1. ActiveX Control.
2. ActiveX Code – EXE or DLL.
3. ActiveX Document – EXE or DLL.
To add an ActiveX control to the toolbox.
From the project menu, choose components.
Select the check box next to the name of the .OCX control, and then choose OK. Once a control is placed in the toolbox, you can add it to a Form just as you would an intrinsic control.
To Create an ActiveX Control.
The foundation for creating an ActiveX Control is the User Control object.
The User Control object can contain code as well as visual objects like text box, list box, etc. which are standard controls.
The User Control is like the form object and adding controls to it is similar to adding controls to a form object.
The User Control object files has the extension .CTL and the graphical elements on the user control is stored in files with extension .CTX
The User Control object that is created may be used in any application and the user may resize the User Control. In which case the behaviour of the user control must be coded in the UserControl_resize() event.
To remove an ActiveX control.
Remove all instances of the control from the forms in your project. Delete any references to the control in the project’s code. If references to a deleted control are left in your code, an error message will display when your compile the application.
From the Project menu, choose components.
Clear the check box next to the name of the .OCX control, and then choose OK. An error message will display if there are remaining instances of the control in your project.
Q1. What is the significance of the procedure and the function in VB. ?
A1. Procedures :
1. Procedure allow us to break programs into discrete logical units each of which can be debugged more easily than an entire program without procedures.
2. Procedures used in one program can act as building blocks for other programs, usually with little or no modification. There are several type of procedures in VB.
A procedure can be a Sub, Function or Property procedure.
sub procedures do not return value
function procedures return a value
property procedures can return and assign values and set references to objects
Functions :
Visual Basic Includes system-provided, or intrinsic function, like Sqr, Cos, Chr. In addition we can use the function statement to write our own function procedures.
Like a sub procedure a function procedure is a separate procedure that can take arguments, perform a series of statements, and change the value of its arguments. The arguments for a function procedure work in exactly the same way as the arguments for a sub procedure. Aside from the function keyword, there are three differences between sub and function procedures.
Generally we call a function by including the function procedure name and arguments in the right side of the larger statement or expression.
function procedures have data types just as variables do. This determines the type of the return value. (in the absence of an as clause, the type is the default variant type.)
we return a value by assigning it to the procedure name itself. When the function procedure returns a value, this value can then become part of a larger expression.
Q2. What is OLE? Why do you use this in VB? Explain.
A2. OLE is the abbreviation for object linking and embedding. A program that includes OLE capabilities can communicate data (text and graphics) to other window applications that are OLE based.
Adding the OLE control to a Form.
To add the OLE control to a form, double click on the OLE – icon in the toolbox. Visual Basic responds by placing the OLE control in the form and displaying the insert object dialog box. The insert object dialog box displays a list of objects that can be embedded in a program.
select the item bitmap image from the list of objects, then click on OK.
save the project.
run the project.
Double click on the OLE control on the form and the object to which it has been linked will be executed. Paintbrush will be executed in our example.
Adding the OLE control to a Form to run a power point presentation.
1. Add the OLE control to a form, double click on the OLE – icon in the toolbox. Visual basic responds by placing the OLE control in the form and displaying the insert object dialog box.
2. Select power point presentation and indicate the power point presentation file.
3. Save and run the project.
Q3. Discuss the use of Multiple Document Interface application.
A3. The multiple document interface(MDI) allows you to create an application that maintains multiple forms within a single container form. Applications such as Microsoft excel and work for windows have multiple-document interfaces.
An MDI application allows the user to display multiple documents at the same time, with each document displayed in its own window. Document windows are contained in a parent window, which provides a workspace for all the document windows in the application.
Your application can have only one MDI form, which contains all the applications child forms. At runtime, child forms are displayed within the internal area of the MDI form (the area inside the form’s borders and below any caption and menu bars). When a child form is minimized its icon appears on the MDI form instead on the desktop. Any application can also include standard, non-MDI forms that are not contained in the MDI from. A typical use of a standard form in an MDI application is to display a modal dialog box.
Q4. Explain the objects available in VB to access the database.
A4. Jet Database
Database created by using the jet database engine. Microsoft access also uses the jet database engine as its data manager component.
ODBC databases (open data base connectivity)
Open data base connectivity (ODBC) provides a universal database connectivity application programming interface (API) that enables applications to access data in a wide range of proprietary databases. Based on the X/Open SQL Access Group’s Call Level Interface (CLI) specification, ODBC is an open vendor – neutral way to uniformly access data stored in different formats and database engines. ODBC is the most widely used interface to relational data. As the standard interface to relational data, your application can access a lot of data using ODBC. ODBC databases include Microsoft SQL Server, Sybase, Oracle etc.
ISAM databases (Indexed Sequential Access Method)
ISAM databases include FoxPro, Microsoft visual FoxPro, Paradox etc.
Data in the following databases can be accessed in visual basic using the following options.
Data Control: Uses the Jet Database engine to retrieve data from jet databases (like MS-ACCESS) and ISAM databases like FoxPro, Paradox etc.
DAO – Data Access Objects: Uses the Jet Database engine to retrieve data from jet databases (like MS-ACCESS) and ISAM databases like FoxPro, Paradox etc.
RDO – Remote Data Object: Remote Data objects and collections provide a framework for using code to create and manipulate components of a remote ODBC database system. The RDO is only supported on 32-bit operating system such as Windows 95 and Windows NT. To use the Remote Data Objects, you must set a reference to the Microsoft Remote Data Objects 2.0 object library in the visual basic references dialog box.
ADO –ActiveX Data Object: ADO is designed as an easy-to-use application level interface to Microsoft’s newest and most powerful data access paradigm, OLE DB. OLE DB provides high-performance access to any data source, including relational and non-relational databases, email and file systems, text and graphics, custom business objects etc.
ODBC API: API stands for Application Program Interface, which is a collection of low-level functions, which can be called directly from within a visual basic application. ODBC also supports a set of API functions, which can be called to connect to a database.
Q5. What are ActiveX Components? How do you create ActiveX controls? Explain.
A5. ActiveX is based on an old technology known as OLE (Object Linking and Embedding) extended with technology to support Internet. The possible components of this technology are:
1. ActiveX Control.
2. ActiveX Code – EXE or DLL.
3. ActiveX Document – EXE or DLL.
To add an ActiveX control to the toolbox.
From the project menu, choose components.
Select the check box next to the name of the .OCX control, and then choose OK. Once a control is placed in the toolbox, you can add it to a Form just as you would an intrinsic control.
To Create an ActiveX Control.
The foundation for creating an ActiveX Control is the User Control object.
The User Control object can contain code as well as visual objects like text box, list box, etc. which are standard controls.
The User Control is like the form object and adding controls to it is similar to adding controls to a form object.
The User Control object files has the extension .CTL and the graphical elements on the user control is stored in files with extension .CTX
The User Control object that is created may be used in any application and the user may resize the User Control. In which case the behaviour of the user control must be coded in the UserControl_resize() event.
To remove an ActiveX control.
Remove all instances of the control from the forms in your project. Delete any references to the control in the project’s code. If references to a deleted control are left in your code, an error message will display when your compile the application.
From the Project menu, choose components.
Clear the check box next to the name of the .OCX control, and then choose OK. An error message will display if there are remaining instances of the control in your project.
0 comments: