Professional Documents
Culture Documents
Lab Manual
MCA-E592B
Windows Programming Lab
Prepared By:
Ammlan Ghosh
Assistant Professor
Department of Computer Application
Note: Use each control’s TabIndex property to contrl the order in which the user will navigate
through the form when pressing the TAB key.
2. Add the appropriate labels for the textboxes on the hotel reservation form, as shown in
Figure.
5. Add a Label Controls with the Caption property set to Check-in-Date. Position the
label to the left of the MaskEdBox control.
8. Click OK
End Sub
Note: In the next assignment example you have to continue from this project. So do the
project carefully. If you have not changed the properties of the control, as it is stated, you
will face problem.
In this lab you will add form and field level validation to the Hotel Rajdarbar
Reservation system. You will modify control properties and add code to control events to
validate data entered into the form. In subsequent labs, you will continue to add to the
application and explore each of the tasks you try here in more detail. You can continue to
work with the files you create in Assignment Example one.
Open the Hotel Rajdarbar Reservation Project you have saved in the Assignment
Example one.
End Sub
End Sub.
3. The DisableControls procedures code will loop through the controls collection using
the For Each … Statement. It will disable all but he Munu and Label contgrls,a dn set
the MaskEdBox and the Text box control’s BackColor property to gray. Add the
following code to the DisableControls procedure.
Note: At the end of the Disable controls procedure those three lines will disable Check-In,
Check-Out and the Cancel Reservation menu Items.
4. The EnableControls procedure will enable all of the controls, including the menu
items, and returns the TextBox and MaskEdBox control’s Back Color to White. The
finished code should look like the following.
ctl.Enabled = True
B. Field-Level Validation
In this exercise, you will use the IsNumeric function and the KeyPress event to
validate user input on the reservation form.
2. Use the KeyPress evnet of the Phone Number text box to accept only numbers,
parenthesis(), hypens(-) and the Backspace characters. If incorrect values are
entered, beep and then display a message to the addinfo panel of the StatusBar
Control. The finished code should look like the following:
4. Using the KeyPress events of the txtNumPeople, txtNumDays and txtRate text
boxes, verify tha a numeric value is type. Be sure to allow the user to press the
BackSpace key. This example shows the completed txtNumPeople_KeyPress event.
2. In the txtNumDays_LostFocus event, add the following code to calculate and format
the guest’s checkout date:
End Sub
3. Set the Locked property of the Checkout date text box to true.
4. Save and test the application.
In this exercise, you will check that the required values were entered in to the form
before letting the user continue.
Note: After successfully completing these two examples you will be able to do different
types of validations, creating menus, adding ActiveX controls and others. In next lab
session you will get different exercise that has been covered in these two examples.
In this exercise, you will connect to a database using the ADO Data control’s
property pages.
9. Or you can collect the database from the faculty in the lab and save it into your
VBPractice Folder.
1. Open the Components Dialog Box (press Ctrl+T) to add the Microsoft ADO Data
Control 6.0 (OLE DB) component to the toolbox.
2. Place an ADO Data Control on frmReservation as illustrate in the figure.
1. Set the ADO Data Control’s Name property to adcReservation, and the Caption
property to Reservation.
2. Use the ADO Data Control’s property pages (right click on the Adodc and click on
ADODC Property) to create a connection string using the Microsoft Jet OLE DB
provider to connect to the Rsvn.mdb database located in your VBPractice Folder.
6. Set the RecodrdSource property of the ADO Data Control to use a command Type of
2-adCmdTable, and use Reservation as the Table or Stored Procedure Name, as
illustrated in Figure.
3. Type the following code statement before the End Sub statement in the
DisableControls Sub procedure
adcReservation.Enabled = True
The user will now be abel to use the ADO Data control to navigate between records
in the Reservation table.
4. To have the Payment Type option buttons programmatically display the correct type
of payment (Credit Card, Cheque or Cash) from adcReservation recordset, add the
following code to the adcReservatio_MoveComplete event. (Double click on the
adcReservation and Select MoveComplete event from the event list)
strStatus = adcReservation.Recordset![PaymentType]
MsgBox strStatus
Select Case UCase(strStatus)
Case "CREDIT CARD"
grpPmtType(0).Value = True
Case "CHEQUE"
grpPmtType(1).Value = True
Case "CASH"
grpPmtType(2).Value = True
End Select
dtCheckIn = adcReservation.Recordset![CheckInDate]
intNumDays = adcReservation.Recordset![NumberOfDays]
End Sub
In this exercise you will declare Record set and Connection object variables. These
variables will be used in Exercise 2. You will also create a custom search form t allow users
to locate guest records.
2. Place three Label and TextBox Controls and one CommandButton on frmSearch,
and set the following properties.
In this exercise, you will write ADO code to query the Reservation table in the
Rsvn.mdb database. The rsReservation Reecordset object that you created in Exercise 1 will
be based on information that the user enters into the fields on frmSearch.
frmSearch.Show vbModal
Unload frmSearch
Set frmSearch = Nothing
cnReservation.ConnectionString = _
"Provider = Microsoft.Jet.OLEDB.3.51;" & _
"Data Source=Rsvn.mdb"
cnReservation.Open
Point to be noted:
i) According to the user’s choice the Label with the text box will be changed.
(i.e. if he chooses Fahrenheit to Centigrade the first text box associated label will
be Fahrenheit and second text box associated label will be Centigrade)
ii) If user clicks on the close button in the form program will display a
message saying “Click on the Exit Button to exit”.
2. Develop a Program that will count the number of words written in a text box. Output
form of this program may like this. (Note the text box properties. It supports Multi
Line and Scroll Bars
In this form user will enter a number in the 1st text box and get the changed number in
the text box2 according to chosen option from the List Box. Four options are available in the
list box
a. Reverse the Number It will reverse the given number.
b. Sum of its Digits it will find the sum the digits of the given number i.e. if
the given number is 532 out put will be 5+3+2 , 10
c. Sum of its Digits cube. d. Refresh Clear the content of the text boxes.
1. Develop a program that uses three Horizontal scroll bars to change the Red Green
Blue colors of two picture box. Each scroll bar has two events Change() and Scroll().
Change event will change the Picture box 2’s back color and Scroll event will change
the back color of Picture Box 1’s Back color according to these three scroll bar’s value.
Q2. Develop a Tic-Tac-Toe Game. Form lay out may be like this.
Q3. Develop an image browser with stretch option using a common Dialog Box
Q4. Create a Progress Bar using line drawing in Picture box , with the progress bar
exhibiting all the VIBGYOR Colours.
Dept. of Computer Application, SIT 32 | P a g e
Laboratory Manual MCA-E592B