Course Code : CS-65
Course Title : Windows Programming
Assignment Number : BCA(4)-65/Assignment/2010
Maximum Marks : 25
Last Date of Submission : 30th April, 2010 (For January Session)
30th October, 2010 (For July Session)
There are five questions in this Assignment. Answer all the questions. You may use illustrations and diagrams to enhance explanations.
Question 1: Design a database application to generate Cinema Hall Transactions using Visual Basic. Provide necessary documentation, reports, screen layouts etc. for the project.
(7 Marks)
Solution:
==================================================================================
Question 2: What is a significance of Crystal Reports? How are these used? Explain.
(3 Marks)
Solution: 'Crystal Reports' is a popular third party package that is included with Visual Basic, which allows you to create reports for your application. The package consists of a designer - where you can design and test the reports, Crystal Reports API calls and Crystal Reports control.
Note: Crystal Reports is shipped and installed as part of the VB installation package except in VB6. This can be found in \common\tools\crysrep double click on crystl32.exe to install.
Creating a Report
VB5 or less
To access the Crystal Report Designer, select the Report Designer from the Add-In menu in the VB environment
To access the Crystal Report Designer, select the Report Designer from the Add-In menu in the VB environment
VB6
To access the Crystal Report Designer, a Start menu group and shortcut will have been automatically created.
To access the Crystal Report Designer, a Start menu group and shortcut will have been automatically created.
Lets have a quick look at the Designer
Initially there is one tab on the report - Design - when you select the print preview to see how the report looks with data in, another tab named Preview will appear.
While you are in design mode you can draw and arrange the data fields on the report. This is done in a similar way to creating controls on a form in VB.
For the purposes of this tutorial we will be creating a simple report from the sample database BIBLIO.
Start the Crystal Reports Designer
Create a new report by choosing File menu - New and the Create New Report dialog box will appear (see picture below)
Click on the Custom button to display the Choose Report Type and Data Type frames.
Select the Custom Report and click on the Data File.
Specify the location of the BIBLIO.MDB Access database
Select which tables from the database you want. For this example we will need the authors table and the Title table.
check that the joins are correct in the Linking Export
Now we are ready to draw the report
Drag and drop the fields you want on to the report. So that it looks like the report above.
Now if you run it by selecting Print Preview, you can see what the report looks like.
Now save the report and we have a template that now can be used in VB.
Note: Turn off the Save Data with report option if you want the data to contain new information each time the report is used. Going to the File menu, selecting Options and clicking on the Reporting Tab sets the option
This is fine I hear you say, but what if I don't want all the data. There are many options in the Crystal Reports and as this tutorial is more of an overview I will not be going into it. But one important thing to do is to get specific data. This is done by a selection formula (i.e. the Where clause of a SQL statement).
The above formula will only show Authors that have had their book published in 1984.
Using Crystal Reports in VB
When you have designed your report, the saved file should have an extension .rpt. You can use this report with the Crystal Report control to display or print your report in a VB application.
Note:Check the crystal report help files for the files you need to distribute with the control. You will also need any .rpt files that you have created
You will have to add the Crystal Report control to the toolbox, this is done by going to the Project menu and selecting Components, then looking down the list for the control and clicking on it
To use the control add it to a form and set the following properties
- ReportFileName - The path and the filename of the .rpt file you have created
- DataFiles(0) - The path and the filename of the database that you want it to use.
If this is left blank it will use the one in the report. - SelectionFormula - The formula to select the subset of data that you want.
- Destination - 0 to Preview, 1 to Print
To display the report use the .printreport method i.e CrystalReport1.PrintReport
==================================================================================
Question 3: What are different the built-in functions and their use in Visual Basic. Also, discuss the need of Module level variables with example.
(5 Marks)
Solution:
Function | | |
Name | Return Type | Description |
CBool | Boolean | Converts an expression into a Boolean value |
CByte | Byte | Converts an expression into Byte number |
CDate | Date | Converts and expression into a date or time value |
CDbl | Double | Converts an expression into a flowing-point (decimal) number |
CInt | Integer | Converts an expression into an integer (natural) number |
CCur | Currency | Converts an expression into a currency (monetary) value |
CLng | Long | Converts an expression into a long integer (a large natural) number |
CSng | Single | Converts an expression into a flowing-point (decimal) number |
CStr | String | Converts an expression into a string |
A variable that is recognized among all of the procedures on a module sheet is called a "module-level" variable. A module-level variable is available to all of the procedures in that module, but it is not available to procedures in other modules. A module-level variable remains in existence while Visual Basic is running until the module in which it is declared is edited. Module-level variables can be declared with a Dim or Private statement at the top of the module above the first procedure definition.
At the module level, there is no difference between Dim and Private. Note that module-level variables cannot be declared within a procedure.
Note If you use Private instead of Dim for module-level variables, your code may be easier to read (that is, if you use Dim for local variables only, and Private for module-level variables, the scope of a particular variable will be more clear).
In the following example, two variables, A and B, are declared at the module level. These two variables are available to any of the procedures on the module sheet. The third variable, C, which is declared in the Example3 macro, is a local variable and is only available to that procedure.
Note that in Example4, when the macro tries to use the variable C, the message box is empty. The message box is empty because C is a local variable and is not available to Example4, whereas variables A and B are.
At the module level, there is no difference between Dim and Private. Note that module-level variables cannot be declared within a procedure.
Note If you use Private instead of Dim for module-level variables, your code may be easier to read (that is, if you use Dim for local variables only, and Private for module-level variables, the scope of a particular variable will be more clear).
In the following example, two variables, A and B, are declared at the module level. These two variables are available to any of the procedures on the module sheet. The third variable, C, which is declared in the Example3 macro, is a local variable and is only available to that procedure.
Note that in Example4, when the macro tries to use the variable C, the message box is empty. The message box is empty because C is a local variable and is not available to Example4, whereas variables A and B are.
Dim A As Integer ' Module-level variable.
Private B As Integer ' Module-level variable.
Sub Example1()
A = 100
B = A + 1
End Sub
Sub Example2()
MsgBox "The value of A is " & A
MsgBox "The value of B is " & B
End Sub
Sub Example3()
Dim C As Integer ' Local variable.
C = A + B
MsgBox "The value of C is " & C
End Sub
Sub Example4()
MsgBox A
' The message box displays the value of A.
MsgBox B
' The message box displays the value of B.
MsgBox C
' The message box displays nothing because C was a local variable.
End Sub
==================================================================================
Question 4: List the controls and items those can/cannot be implemented over Multiple Document interface (MDI). Also, discuss the use of MDI in the development of Visual Basic application.
(5 Marks)
Solution: A document management system (DMS) is a computer system (or set of computer programs) used to track and store electronic documents and/or images of paper documents. The term has some overlap with the concepts of content management systems. It is often viewed as a component of enterprise content management (ECM) systems and related to digital asset management, document imaging, workflow systems and records management systems.
In the broadest sense, document management systems can range from a shoebox all the way to an enterprise content management system. There are several common issues that are involved in managing documents, whether the system is an informal, ad-hoc, paper-based method for one person or if it is a formal, structured, computer enhanced system for many people across multiple offices. Most methods for managing documents address the following areas:
Location | Where will documents be stored? Where will people need to go to access documents? Physical journeys to filing cabinets and file rooms are analogous to the onscreen navigation required to use a document management system. | |
Filing | How will documents be filed? What methods will be used to organize or index the documents to assist in later retrieval? Document management systems will typically use a database to store metadata about documents and a File System to store the actual physical files. | |
Retrieval | How will documents be found? Typically, retrieval encompasses both browsing through documents and searching for specific information. What kind of information about documents are indexed for rapid retrieval? | |
Security | How will documents be kept secure? How will unauthorized personnel be prevented from reading, modifying or destroying documents? | |
Disaster recovery | How can documents be recovered in case of destruction from fires, floods or natural disasters? | |
How long should documents be kept, i.e. retained? As organizations grow and regulations increase, informal guidelines for keeping various types of documents give way to more formal records management practices. | ||
How can documents be preserved for future readability? | ||
Distribution | How can documents be available to the people that need them? | |
Workflow | If documents need to pass from one person to another, what are the rules for how their work should flow? | |
Creation | How are documents created? This question becomes important when multiple people need to collaborate, and the logistics of version control and authoring arise. | |
Authenticity | Is there a way to vouch for the authenticity of a document ? | |
When, where and by whom are documents created, modified, published and stored [1]? | |
==================================================================================
Question 5: What is data control? Explain the use of different data controls available in
Visual Basic with example. (5 Marks)
Solution: The Visual Basic 6.0 Data control is used as a mechanism for binding controls to a database using DAO. Visual Basic 2005 has no equivalent for the Data control; the data-binding architecture has changed and DAO is no longer supported. For more information, see Data Access for Visual Basic 6.0 Users.
The Data control also provides an interface for navigating data, with buttons for moving back and forth through rows in a database table. Visual Basic 2005 has an equivalent control, the BindingNavigator control, which also contains buttons for adding and deleting rows
The Visual Basic 6.0 Data control is used as a mechanism for binding controls to a database using DAO. Visual Basic 2005 has no equivalent for the Data control; the data-binding architecture has changed and DAO is no longer supported. For more information, see Data Access for Visual Basic 6.0 Users.
The Data control also provides an interface for navigating data, with buttons for moving back and forth through rows in a database table. Visual Basic 2005 has an equivalent control, the BindingNavigator control, which also contains buttons for adding and deleting rows.
==================================================================================
By Nikhil Trivedi
No comments:
Post a Comment