Q1. What do you understand by event driven programming? List and explain about some of the events supported by Visual Basic Objects.
Answer: Visual Basic is an event driven programming language. Before proceeding to the next chapter, it is very important to have a good concept of event driven programming. The common events are Click, DblClick, Load, MouseMove, MouseDown, MouseUp, KeyPress, KeyUp, KeyDown, GotFocus, LostFocus etc.
When the user clicks, presses key or moves the mouse, the particular block of code of the corresponding event procedure is executed. Then the program behaves in a certain way. This is event driven programming. When you fire an event, the code in the event procedure is executed, and then visual basic does what the code in the event procedure instructs to do. For example, in the first sample program, when you click the Print button, click event is fired. Then the code in the click event procedure gets executed. The code instructs to print a text on the form. After that you see a text printed on the form. This is the concept of event driven programming. That means, the code is not executed from top to bottom but it works when the corresponding event procedure is invoked.
Write the following code in the DblClick event procedure of the form.
Private Sub Form_DblClick ()
Print "You have double clicked"
When you double-click on the form, the DblClick event procedure of the Form object is invoked and the code in the DblClick event procedure is executed. As a result, the code instructs to print a text on the form.
Q2. What are the different data types supported by Visual Basic? How they can be declared? Also mention their uses.
Answer: There are a number of different data types supported by Visual Basic. The following chart illustrates the most common data types used in Visual Basic:
There are number of ways to declare variables, the Dim statement is the most commonly used to declare variables (think of Dim as short for dimension)
Here is the general form of a variable declaration:
Here are a couple of examples of a variable declaration:
Declare multiple variables of the same type with one declaration statement, as shown in the following example:
Rules for naming variables
- The first character must be a letter or an underscore (_) character
- Maximum 255 characters
- Cannot contain spaces or periods
- Must contain only letters, numbers and underscore character (_); NO PUNCTUATION!
- Cannot contain Visual Basic keywords, such as If, Dim, Time, ElseIf, etc.
A variable declared at the beginning of a procedure is accessible to any statement in that procedure. This means that any statement in the procedure can refer to the variable, change its value, and so on. This variable is said to be local to the procedure because its scope is limited to that procedure. Statements outside the procedure do not have access to the variable.
Q3. Give examples of passing arguments by value and passing arguments by reference in Visual Basic procedures. Solve by www.solvezone.in
Answer: We have two choices regarding how arguments are passed to it: by reference or by value. Basically passes the variable´s address in memory to the procedure, which can modify it directly. When execution returns to the calling procedure, the variable contains the modified value.
When an argument is passed by value, VBA passes a copy of the variable to the procedure. Then, the procedure modifies the copy, and the original value of the variable remains intact; when execution returns to the calling procedure, the variable contains the same value that it had before being passed.
By default, VBA passes arguments by reference. To pass an argument by value, precede the argument with the ByVal keyword in the procedure definition, as shown here:
Function SomeProc (strText As String, _
ByVal lngX As Long) As Boolean
We can preface the argument with the By Ref keyword in the argument list, if want to denote explicitly that an argument is passed by reference.
Passing by reference can be useful as long as we understand how it works. For example, we must pass arrays by reference; we will get a syntax error if we try to pass an array by value. Because arrays are passed by reference, we can pass an array to another procedure to be modified, and then we can continue working with the modified array in the calling procedure.
Q4. Give difference between arrays and dynamic arrays. How they can be created in Visual Basic? Give Syntax.
Answer: Dynamic arrays difference from fixed arrays because a subscript ranges for the array elements is not specified when the array is dimensioned. Instead, the subscript range is set using the ReDim statement. With dynamic arrays, the number of array elements can be set based on other conditions in your procedure. For example, you may want to use an array to store a set of values entered by the user, but you may not know in advance how many values the user will enter. In this case, you dimension the array without specifying a subscript range and then execute a ReDim statement each time the user enters a new value. Or you may want to prompt for the number of values to be entered and execute one ReDim statement to set the size of the array before prompting for the values.
If use ReDim to change the size of an array and want to preserve the contents of the array at the same time, be sure to include the Preserve argument to the ReDim statement:
Redim Preserve Array Name (n)
The following procedure uses a dynamic array, varray, to hold cash flow values entered by the user:
Dim aprate as Single
Dim varray() as Double
Dim cflowper as Integer
Dim msgtext as String
Dim x as Integer
Dim netpv as Double
ReDim varray (cflowper)
For x= 1 to cflowper
Varray (x) =500
If aprate>1 then
msgtext="The net present value is: "
msgtext = msgtext & Format(netpv, "Currency")
Q5. What are the advantage of ADO Data Control? Explain about different objects of ADO model.
Answer: There are few advantages of ADO over data control:
- ADO is faster with most databases compared to data control.
- ADO separates Data handling and Database Structure manipulation, hence it’s easier to protect the database for corruption.
- It supports Hierarchical record-sets and allows to close a connection and still work with a record set
Making ADO objects less dependent on each other has interesting and useful consequences besides just conceptual clarity: As a consequence of the example just given, you can create an ADO Record set object that never has to be connected to an existing data source—and you can therefore use such a disconnected Record set to track and maintain virtual data created entirely within your application or to maintain data from a database offline.
- ADO provides the programmer more opportunities to finetune the data cursor of a Record set. A data cursor (or just a "cursor") represents a set of resources initiated by a data connection that provides a connection to a specific row in a set of data. The data cursor can change position to point to a different row of data. ADO enables you to directly specify where the cursor is implemented (client or server side) and several different types of cursors.
- ADO provides better overall performance than earlier object models.
- ADO is more resource-efficient than earlier object models.
- ADO provides more universal data access, due to the universal nature of its underlying standard, OLE DB.
Following are the objects exposed in the ADO object model:
- Connection object. Specifies information about the physical connection with a data source.
- Command object. Stores information about actions performed on the data, such as data modification and retrieval. You can use a Command object to execute actions on the data or to return data from the server in a Record set object.
- Record set object. Provides a rich selection of properties, events, and methods to expose data in a field-row format, and thus allows you to programmatically traverse, examine, and manipulate specific fields in specific rows of data.
- Parameters collection of the Command object (made up of Parameter objects). Contains information about parameter values that are passed by a Command object.
- Fields collection of the Record set object (made up of Field objects). Contains information about field structure and content of the data in a Record set object.
- Properties collection (made up of Property objects). Contains information about provider-specific properties of Command and Parameter objects.
- Errors collection of the Connection object (made up of Error objects). Contains information about the most recent error that occurred when attempting an ADO operation.
Question 1: Write a program using dynamic arrays to record the high temperatures of last seven days and to display all of them with the average of high temperatures. Use three buttons on the screen, one to enter the temperature, second to display the result and third to exit from program.
Answer: Here an example in VBA (Visual Basic for Application - Office):
Steps to do:
1) Open MS Excel (new workbook is created)
2) Use ALT+F11 to go to MS Visual Basic for App COde Editor
3) Use Menu: Insert->User Form
4) Add controls to User Form:
- 1x List Box (change property "Name" to LstTemp
- 3x Command Buttons (change property "Name" to: CmdAddTemp, CmdDisplay, CmdExit)
- 1x Textbox (change property "Name" to: TxtAvgTemp)
5) Copy code below
6) Paste it into User Form module
7) Have a fun Wink | ;)
´set arrays low bound = 0
Option Base 0
´array to store temp
Dim a Temp() As Single
Dim iArr As Integer
Private Sub UserForm_Initialize()
´coz array start from 0 (zero)
iArr = 0
Private Sub CmdAddTemp_Click()
Dim sTemp As String
´on error goto error handler
On Error GoTo Err_CmdAddTemp_Click
sTemp = InputBox("Enter temperature", "Enter value...", "0")
´when Cancel button was pressed
If sTemp = "" Then GoTo Exit_CmdAddTemp_Click
´change array size
ReDim Preserve aTemp(iArr + 1)
´check for numeric value using convertion
´when it´s not numeric go to error handler
aTemp(iArr + 1) = CSng(sTemp)
´get new array size
iArr = UBound(aTemp)
´add temperature on the end of list
´catch all errors including convertion errors
Select Case Err.Number
Case 13 ´can´t convert value to single
MsgBox "Enter corect value of temperature!", vbExclamation, "Error no. " & Err.Number
MsgBox Err.Description, vbExclamation, "Error no. " & Err.Number
Private Sub CmdDisplay_Click()
Dim i As Integer, avgTemp As Single
For i = LBound(aTemp) To UBound(aTemp)
avgTemp = avgTemp + aTemp(i)
´divide by array size to get average temperature
avgTemp = avgTemp / UBound(aTemp)
´display returned value
Me.TxtAvgTemp = avgTemp
Q2. Write a small hand calculator. Use command buttons for the number keys, the Enter key and the + key etc. Use a label to display the results.
Answer: The logic is fairly simple:
- For 0-9: The content of the textbox gets appended as soon as you press any of these keys.
- For +,-,*,/ : The content of the textbox (Operand 1) is stored in a variable and the textbox is cleared to enable the user to enter the second operand.
- For decimal: If the textbox is empty then "0." is appended else simply a decmal.
- For Eqaul: the entire logic is on pressing the = key...The result of the calculation is displayed in the text box using switch case.
Dim i As Integer
Dim a, b As Double
Private Sub Command1_Click()
Text1.Text = Text1.Text + "1"
Private Sub Command2_Click()
Text1.Text = Text1.Text + "2"
Private Sub Command3_Click()
Text1.Text = Text1.Text + "3"
Private Sub Command4_Click()
Text1.Text = Text1.Text + "4"
Private Sub Command5_Click()
Text1.Text = Text1.Text + "5"
Private Sub Command6_Click()
Text1.Text = Text1.Text + "6"
Private Sub Command7_Click()
Text1.Text = Text1.Text + "7"
Private Sub Command8_Click()
Text1.Text = Text1.Text + "8"
Private Sub Command9_Click()
Text1.Text = Text1.Text + "9"
Private Sub Command10_Click()
Text1.Text = Text1.Text + "0"
Private Sub Command11_Click()
Text1.Text = ""
Private Sub Command12_Click()
If Text1.Text = "" Then
Text1.Text = Text1.Text + "0."
Text1.Text = Text1.Text + "."
Private Sub Command13_Click()
i = 1
a = Val(Text1.Text)
Text1.Text = ""
Private Sub Command14_Click()
i = 2
a = Val(Text1.Text)
Text1.Text = ""
Private Sub Command15_Click()‘*
i = 3
a = Val(Text1.Text)
Text1.Text = ""
Private Sub Command16_Click()
i = 4
a = Val(Text1.Text)
Text1.Text = ""
Private Sub Command17_Click()
If i = 1 Then
b = Val(Text1.Text)
Text1.Text = a + b
If i = 2 Then
b = Val(Text1.Text)
Text1.Text = a - b
If i = 3 Then
b = Val(Text1.Text)
Text1.Text = a * b
If i = 4 Then
b = Val(Text1.Text)
Text1.Text = a / b
Q3. Develop a WordPad application using MDI forms, having basic features of File and Edit.
Answer: To Develop an MDI Application take the following steps (Describe with details in Page 12 to 22 Pages):
1. Create a new project using File -> New Project and select Standard Exe as the type of the project.
2. At this stage a new project is created with just one form. The form that is created by Visual Basic is a normal form. But as our application is based on MDI, it needs an MDIForm.
3. Add an MDIForm to project using Project -> Add MDIForm.
4. Visual Basic adds an MDIForm to the current project.
5. After MDIForm is added to current project, Add MDIForm option in Project menu will be disabled. Remember there can be only one MDIForm in a Visual Basic project.
Adding Menu to Application
Add required menus to MDIForm by following the steps below.
1. Make MDIForm active form in the project.
2. Select Tools->Menu Editor
3. Add the following menu using Menu Editor
New Creates a new document. It creates a new child form and displays empty window.
Open… F3 Allows user to select a text file. Creates a new child window and displays the contents of the text file for editing in that window.
Close closes the currently active document. Takes confirmation before closing a document, if document was modified but not saved.
Save F2 Saves changes made to current document. If current document is a new document, it will prompt user to enter a filename using Save As dialog box.
Save As Allows current document to be saved under a different filename.
Print Prints the current document to printer.
Exit terminates the application. Takes confirmation before the application is terminated.
Cut Ctrl + X Cuts the selected text in the current document and places the text on the clipboard.
Copy Ctrl + C Copies the selected text in the current document to clipboard.
Paste Ctrl + V Extracts text from clipboard and pastes it into current document.
Cascade F5 Arranges all open windows using cascade format, where title bars of all open windows will be displayed.
Tile Horizontal Tiles all open windows horizontally.
Tile Vertically Tiles all open windows vertically.
Arrange Icons Arranges all minimized windows.
Windows list Displays captions of all open child forms.
About Displays about dialog box.
Displaying Window List
One of the common features of an MDI application is Window menu displaying list of open windows. For example, in MS-Word, you get the list of open documents at the end of the window menu. Visual Basic IDE is also an MDI application. If you see Window menu of Visual Basic IDE while working with a project. As you can see at the Window Menu the list of open windows are displayed
To display windows list in MDI application:
1. Invoke Menu Editor of MDIForm using Tools -> Menu Editor when MDIForm is active
2. Select Window menu in the list of menu. As we want to display list of windows at the bottom of Window menu.
3. Turn on WindowList checkbox
That’s all you have to do to display the list of windows at the bottom of Window menu. Visual Basic takes care of adding and removing windows from the list as you open and close documents.
Enabling the display of list of windows at the bottom of Window menu
Making Form1 MDIChild form
Now our project contains two forms – MDIForm1 and Form1. MDIForm1 is the parent that forms the base for the application. Form1 is the form that displays the contents of the file and allows user to edit. We take multiple copies of Form1 at run time to display multiple documents. In order to display copies of Form1 within MDIForm1, first we have to make Form1 a child form.
To make Form1 an MDI Child form:
1. Invoke Properties Window of Form1 by selecting the form and pressing F4.
2. Change MDIChild property to True.
Child form will display the contents of the selected file and also allows user to edit the contents. To display the contents of the selected file, we place a text box in child form. The textbox will occupy the entire client area of the child form and it also contains scrollbars to allow user to scroll.
Place a textbox and change its property as follows.
1. Place a textbox on the form. The position and size of the textbox are not so important because they are changed at run time using Resize event (see listing 12.1) of the form so that textbox occupies the entire client area of the form.
Private Sub Form_Resize() ‘Make textbox occupy the entire client area’.
Text1.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
Listing 12.1: Filling the entire client area of the form using resize event of the form.
2. Change the MultiLine property to True, and Scrollbars property to 3-both.
Changing Startup Object of the Project
If you run the project now, Form1 will be displayed as the first form. But we want MDIForm to be displayed first. To display MDIForm1 as the first form in the project we have to change Startup Object property of the project.
To change startup object:
1. Select Project -> Project Properties (In place of Project in Project Properties option, the name of the current project name is displayed).
2. Visual Basic displays project properties dialogbox .
3. Select General tab if it is not selected.
4. From Startup object drop down, select MDIForm1 to make MDIForm1 the startup object.
5. Click on Ok to close properties dialogbox.
Now, if you run the project, MDIForm1 will be displayed as the first form
Writing code for Options in File menu
The following section will explain the code for options of File menu.
Writing code for New option
We will now write code for New option of File menu. When user selects New option from File menu a new window is to be displayed so that user can start typing text. Subsequently, if user chooses Save option then the typed contents will be saved under the given name.
New option creates a new copy of Form1 and displays that copy with Noname as the caption of the form. As we have to prompt user, if user is trying to close the document without saving changes, we use Tag property of the form. Tag property of the form will be set to 0 in the beginning. Tag property is set to 1 whenever user makes a change to the content. Again Tag is set to 0 when user saves changes. That means at the time of closing document if Tag is set to 1, it means user is trying to close a document that was modified but not saved. In this case, program has to prompt user to save pending changes. We will create code for close option later.
Here is code for new option.
Private Sub mnunew_Click()
Dim f As New Form1 ‘ create a new copy of Form1
f.Caption = "Noname"
f.Tag = 0 ´ not modified
f.Show ‘ display form
Listing 12.2: Code for new option of file menu.
Writing code for Open Option
For this option, as we have to prompt the user to select a filename. First of all to use open dialog, we have to load common dialog control into project.
To load common dialog control:
1. Select Project-> Components
2. Move down until you get to Microsoft Common Dialog Control 6.0 and select it (turn on the checkbox).
3. Click on Ok button
Visual Basic places the control in Toolbox.
4. Place common dialog control on MDIForm1.
Open option of File menu does the following:
• Accepts a filename from user through Open common dialog box.
• Creates a new instance of Child form (Form 1).
• Loads the content of selected file into the text box of child form.
• Displays the child form.
Here is the code for Open option of File menu.
Private Sub mnuopen_Click()
‘Create a New instance of form
Dim nf As New Form1
Dim oneline As String, filecontent As String
´ trap error that might occur
On Error GoTo errlbl
´ display open dialog box to user
.Filter = "Text files|*.txt|All files|*.*"
´cause error if user doesn´t select any file
.CancelError = True
´ user has selected a file. Read the content and display content
´ in textbox
´ change mouse pointer to indicate system is busy
Screen.MousePointer = vbHourglass
´ open file
Open .FileName For Input As #1
Do Until EOF(1)
´ read one line at a time
Line Input #1, oneline
´ concatenate line along with new line to lines read so far
filecontent = filecontent & oneline & vbCr & vbLf
´ load the text into textbox of child form
nf.Text1 = filecontent
´ set Tag to 0 to indicate that content is not modified
nf.Tag = 0
´ change caption to file name
nf.Caption = .FileName
´display child form
´ reset mouse pointer
Screen.MousePointer = vbDefault
´ ignore the error and free memory allocation to nf and quit
Set nf = Nothing
Listing 12.3: Code for Open option of File menu.
Writing code for Save and Save As options
Save option saves the changes made to current form. If current form contains a new document (with caption property set to Noname) then Save option works like Save As, otherwise Save saves the changes made to current document.
Save As prompts the user to enter a new filename and then saves the contents in the new filename.
This is also invoked by Save option when user is saving a new document.
As both Save and Save As options write the document into a file, it is better to implement code as a separate procedure.
General procedures such as SaveFile in this case, are accessed generally from more than one form. So it is better to create a code module and place all such general procedures into code module because procedure placed in code module can be accessed through the project.
Creating SaveFile procedure in Code module
First let us create a new code module and then create a SaveFile procedure in code module.
To add a code module to project:
1. Select Project -> Add Module.
2. Visual Basic adds a code module to project with default name Module1.
To create SaveFile procedure:
1. Make code module active.
2. Select Tools -> Add Procedure option.
3. When Visual Basic displays Add Procedure dialog box, enter SaveFile as the name of the procedure and click on Ok.
4. In code window enter the code shown in listing.
Public Sub SaveFile(fn As String, content As String)
Open fn For Output As #1
Print #1, content
´ set tag property to 0 to indicate that
´ changes are saved
MDIForm1.ActiveForm.Tag = 0
Listing 12.4: Code for SaveFile procedure.
The following is the code for Save and Save As options.
Private Sub mnusave_Click()
´ call Save As if name of the file is Noname
If .Caption = "Noname" Then
´ call save as
SaveFile .Caption, .Text1.Text
Private Sub mnusaveas_Click()
´trap error that might occur
On Error GoTo errlbl
´display save as dialog box to user
´ set the file name as the default
.FileName = MDIForm1.ActiveForm.Caption
.Filter = "Text files|*.txt|All files|*.*"
´cause error if user doesn´t any file
.CancelError = True
´ set new file to caption
MDIForm1.ActiveForm.Caption = .FileName
´ save file contents to new filename
SaveFile .FileName, MDIForm1.ActiveForm.Text1.Text
´ignore errors and continue
Listing 12.5: Code for Save and Save As options of File menu.
As you can see from the code, both these event procedures make use of SaveFile procedure created in code module.
Note: ActiveForm property of MDIForm refers to the form that is currently active among child forms.
Code for Close option of File menu
Whenever user chooses Close option from File menu, the active form is to be closed. But if active form has modifications that were not saved then you should prompt the user to save the modifications.
Clicking on close button (X) may also close a child form. In this case also user should be prompted to save modifications.
Prompting user to save changes using QueryUnload event
QueryUnload event occurs just before a form is unloaded. QueryUnload event can cancel unloading form if you set Cancel parameter to True. We use QueryUnload event to prompt the user and take necessary action, as this event occurs in both cases – user clicking on close button of the form and form is getting unloaded because of program executing Unload statement. The second method is used for Close option of File menu.
The following is the code for Close option of file menu.
Private Sub mnuclose_Click()
´ unload active form
Listing 12.6: Code for close option of file menu.
The following is the code for Change event of Text box in child form. This event occurs whenever text in the textbox changes. At this event we set Tag property of the form to 1 to indicate the content of the textbox has changed.
The final in this context is the code for QueryUnload event of the child form.
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
´ check whether changes are pending
If Me.Tag = 1 Then
´ display confirmation box
resp = MsgBox("Do you want to save changes?", vbYesNoCancel _
+ vbQuestion, "Save Changes")
‘ if user has selected Cancel button
If resp = vbCancel Then
´ cancel unload process
Cancel = True
‘ if user has selected Yes to save changes
ElseIf resp = vbYes Then ´ save changes and then quit
SaveFile Me.Caption, Text1.Text
Listing 12.7: Code for Queryunload event of form.
Private Sub Text1_Change()
´ change tag property to indicate modification
Me.Tag = 1
Listing 12.8: Code for change event of text box.
The prompt displayed by MsgBox function will be identical
Message box displayed when user tries to quit without saving changes.
The following will be the action taken for each of the buttons.
Yes Saves the modification and then closes the form.
No Closes the form without saving the modifications.
Cancel Cancels closing process.
Writing code for Print option in File menu
Print option prints the contents of current document to default printer. Printer object is used to print to default printer.
Here is the code to print current document.
Private Sub mnuprint_Click()
´ print current document to printer object
Listing 12.9: Code for print option of file menu.
Writing code for Edit menu
Code for edit menu is much like the code that we have written in chapter 11 for clipboard object. I do not feel any need to explain the code here. For details, please see chapter 11(System Objects).
The code for Cut, Copy and Paste options and Edit menu is given in listing 12.10.
Private Sub mnuedit_Click()
´ disable all options
mnucut.Enabled = False
mnucopy.Enabled = False
mnupaste.Enabled = False
If MDIForm1.ActiveForm.Text1.SelText <> "" Then
´ disable all options
mnucut.Enabled = True
mnucopy.Enabled = True
If Clipboard.GetFormat(vbCFText) Then
mnupaste.Enabled = True
Private Sub mnucopy_Click()
´copy the selected text on to clipboard
Private Sub mnucut_Click()
´copy the selected text on to clipboard
´cut the selected text
MDIForm1.ActiveForm.Text1.SelText = ""
Private Sub mnupaste_Click()
´Place the text that is existing in clipboard at
´the cursor position
MDIForm1.ActiveForm.Text1.SelText = Clipboard.GetText
Listing 12.10: Code for Edit menu and its options.
Writing code for Window menu
All options in window menu make use of Arrange method of MDIForm. Arrange method is used to arrange child forms of MDIForm in the specified format. Here is the complete syntax of Arrange method.
The arrangement may be any of the values given below.
Constant Value Description
vbCascade 0 Cascades all nonminimized MDI child forms
vbTileHorizontal 1 Tiles all nonminimized MDI child forms horizontally
vbTileVertical 2 Tiles all nonminimized MDI child forms vertically
vbArrangeIcons 3 Arranges icons for minimized MDI child forms
Here is the code for options in Window menu.
Private Sub mnucascade_Click()
Private Sub mnuth_Click()
Private Sub mnutv_Click()
Private Sub mnuai_Click()
Listing 12.11: Code for options in Window menu.
Creating About dialog box
Visual Basic provides a template for About dialog box. All you have to do is change the required properties of labels that are placed in the about dialog box. This is the process to add about dialog box to the project.
To add About dialog box to project:
1. Select Project -> Add Form.
Visual Basic displays a list of predefined forms.
2. Select About dialog and click on Open button.
Visual Basic adds an about dialog to current project and form is given name frmAbout.
At design time, About dialog box that is added
To invoke About dialog box:
Write code for click event of About option in Help menu. About dialog box is to be displayed as a modal window (by using vbModal option for Show method).
Private Sub mnuabout_Click()
Listing 12.12: Code to invoke about dialog box.
Note: About dialog box takes properties of current project and fills some of the labels on the form. We have to fill the remaining with the required information.
Now we have reached the end of the development. Now it is time to run the application and test all its features.
1. Run project using Run-> Start option or F5 or by clicking on Start icon in toolbar.
2. When Visual Basic displays MDIForm, choose File->New option to create a new document. Enter some text in the text box.
3. Now try to save this document by pressing F2 or by selecting File -> Save.
4. As the document is new document, Save option will prompt you to enter the name of the file in which the document is to be saved.
5. Enter filename Sample.txt.
6. Close the file by choosing File->Close.
7. Open the file sample.txt using File-> Open.
8. Enter one more line to the document.
9. Try to close the file using File->Close. As we are trying to close without saving the changes, program displays message box prompting you to save changes.
10. Choose Cancel to cancel closing operation.
11. This time click on Close button of the child form.
12. This will also result in the same prompt. Select Yes button in message box to save changes and then quit.
13. Now choose File->New options for a few times to create a few new MDI child windows.
14. Choose Window->Tile Vertical to file windows vertically.
At this stage MDIForm .
15. Exit MDIForm using File->Exit.
Q4. Write an event procedure to automate the billing system of a supermarket. Give the details of database tables, forms, controls and menu design (if any). Make assumptions, wherever necessary.
Answer: Supermarkets are getting crowded these days at the billing area and lot of time is being consumed for billing the products. Also at the counter the person responsible must go through the whole items which have been taken by the customers, it would be a time consuming process. Presently supermarket use barcodes. Regarding the barcodes, generally, a barcode is made up of a series of black and white lines. The cash register uses the data from the code to identify the item and look up its latest price and print the information on the customer’s receipt. Bar codes are commonly used to store data such as prices and stock codes relating to products in the supermarkets.
Details of Database tables, Forms, Controls and Menu Design
Oracle Database 10g is the first database designed for grid computing, the most flexible and cost-effective way to manage enterprise information. It cuts costs of management while providing the highest possible quality of service.
In addition to providing numerous quality and performance enhancements, Oracle Database 10g significantly reduces the costs of managing the IT environment, with a simplified install, greatly reduced configuration and management requirements, and automatic performance diagnosis and SQL tuning.
JDBC (JAVA DATABASE CONNECTIVITY)
JDBC technology is an API(included in both J2SE and J2EE releases) that provides cross DBMS connectivity to a wide range of SQL database and access to other tabular data sources, such as spreadsheets or flat files.
The JDBC API makes it possible to do three things:
- Establish a connection with a database or access any tabular data source
- Send SQL statements
- Process the results
The system aims to trace the position of workers, vehicle and machineries with the help of RFID Technology. With the help of Tomcat Server, the administrator maintains all the details of the workers, vehicle and machineries. Radio-frequency identification (RFID) is the use of an object (typically referred to a san RFID tag) applied to or incorporated into a product, animal, or person for the purpose of identification and tracking using radio waves. Some tags can be read from several meters away and beyond the line of sight of the reader. Radio-frequency identification comprises readers and tags. The chip can store as much as 2 kilobytes of data. To retrieve the data stored on an RFID tag, you need a reader.
Client Side Mobile Phone, which is Access the Internet and Application
Server Side RAM: 256 MB or more
Hard disk: 40 GB hard disk recommended.
Tools: RFID Reader, RFID Tag
Programming language: java1.5 or jdk5, j2me
Tools: J2ME toolkit2.5.2.
Operating system: Windows XP or later
Technology: Java 2 Micro Edition (J2ME)
Operating system: Windows XP or later
Tools: Net Beans IDE 6.9.1
Database: Oracle 10g
Server: Apache Tomcat 6.0
COMMUNICATION INTERFACE: GPRS, RFID Reader, RFID Tag.
Design is the first step in the development phase for any engineering product or system. It may be defined as a "the process of applying various techniques and principles for the purpose of defining a device, a process, or a system insufficient detail to permit its physical realization". Software design is an iterative process through which requirements are translated into a "blue print" for the constructing software. The design is represented at high level of abstraction, a level that can be directly translated to a specific data, functional behaviour requirements.
Input design is the process of converting user-oriented input to a computer based format. Input design is a part of overall system design, which requires very careful attention. Often the collection of input data is the most expensive part of the system. The main objectives of the input design are? Produce cost effective method of input? Achieve highest possible level of accuracy? Ensure that the input is acceptable to and understood by the staff.
Outputs from computer systems are required primarily to communicate the results of processing to users. They are also used to provide a permanent copy of these results for latter consultation. Computer output is the most important and direct source of information to the users.
DATA FLOW DIAGRAM
- VB is considered to be a
(A) First-generation language.
(C) Higher-level language.
(D) Machine language
- The person who actually runs a computer program is called a
- Programming in VB is different from most other programming environments because first you should
(A) Write the code.
(B) Input the data.
(C) Name the buttons.
(D) Draw the user interface.
- GUI stands for
(A) Graphical user interface.
(B) Graphing user introduction.
(C) Graphical unit interface.
(D) Graphical user input.
- Press F4 to
(A) Run a program.
(B) Display the Properties window.
(C) Display the Solution Explorer window.
(D) Terminate a program.
- Which of the properties in a control´s list of properties is used to give the control a meaningful name?
- When a VB program is running, the user can move from one control to another using the keyboard by pressing the
(A) Tab key.
(B) Space bar.
(C) Enter key.
(D) Backspace key.
- Which of the following properties determines the words appearing in a form´s title bar?
- What effect will the following statement have? Label1.Visible = False
(A) Enable Label1
(B) Delete Label1
(C) Make Label1 invisible
(D) It is not a valid VB statement.
- The Font dialog box allows you to select different Fonts, their style, their size, and some other special effects. How do you bring up this Font dialog box?
(A) In the Properties window, click the ellipsis (…) on the right side of the settings box for the Font property.
(B) Double-click the textbox, and select Font Property.
(C) Right-click the textbox, and select Font Property.
(D) None of the above.
- What keyboard shortcut allows you to run the current program?
- Which property is available for most controls that allows you to hide/unhide them either manually by setting the property or by setting it during runtime via code?
- When the user clicks a button, _________ is triggered.
(A) An event
(B) A method
(C) A setting
(D) A property
- Select the code statement that will set the current text color to Red.
(A) txtBox.ForeColor = "Red"
(B) txtBox.ForeColor = Red
(C) txtBox.ForeColor = Color.Red
(D) txtBox.ForeColor = "Color.Red"
- The statement btnButton.Focus()
(A) Has no effect.
(B) Moves the focus to the button btnButton.
(C) Has the same effect as clicking on the button btnButton.
(D) is invalid in VB.
- Which of the following statements sets the words on a button to "Submit Button"?
(A) btnButton.Name = "Submit Button"
(B) btnButton.Text = Submit Button
(C) btnButton.Text = " Submit Button"
(D) btnButton = " Submit Button "
- A user action such as clicking a button is called:
(A) An accident
(B) an event
(C) A procedure