Upload
benedict-van-velasco
View
221
Download
0
Embed Size (px)
Citation preview
8/6/2019 Pracvb Printout-32 Pg
1/30
PROGRAM 1:
Problem Statement:
Write a project to include a textbox for the user to enterhis name. Create four frames which allow the user to choose
Color
Font Styles
Font Size Languages
Include a label which will display Hello World in fourdifferent languages
English
Spanish
French
Italian, depending on the users choice. IncludeDisplay, Clear and Exit command buttons. When the userclicks on the Display command button, the respectiveColor, Font Style and Font Size should get applied to
the contents of the textbox and the label.
Code Window:-
Private Sub cmdclear_Click()With txtname.Text = " ".SetFocus.ForeColor = vbBlack.Font.Bold = True
.FontSize = 12
.Font.Underline = False
.Font.Italic = FalseEnd With
lbldisplay.Caption = " "
End Sub
Private Sub Cmddisplay_Click()'setting styles
If chkbold.Value = 1 Thenlbldisplay.Font.Bold = Truetxtname.Font.Bold = TrueElseIf chkbold.Value = 0 Thenlbldisplay.Font.Bold = Falsetxtname.Font.Bold = FalseEnd IfIf chkitalic.Value = 1 Then
8/6/2019 Pracvb Printout-32 Pg
2/30
lbldisplay.Font.Italic = Truetxtname.Font.Italic = TrueElseIf chkitalic.Value = 0 Thenlbldisplay.Font.Italic = Falsetxtname.Font.Italic = FalseEnd IfIf chkunderline.Value = 1 Thenlbldisplay.Font.Underline = Truetxtname.Font.Underline = TrueElseIf chkunderline.Value = 0 Thenlbldisplay.Font.Underline = Falsetxtname.Font.Underline = FalseEnd If
'setting languageIf optenglish.Value = True Thenlbldisplay.Caption = " Hello world"ElseIf optfrench.Value = True Thenlbldisplay.Caption = " Bonjour tout le monde"ElseIf optitalian.Value = True Thenlbldisplay.Caption = " Ciao Mondo "ElseIf optspanish.Value = True Thenlbldisplay.Caption = " Hola Mundo"End If
'setting fontsizeIf optfont18.Value = True Thenlbldisplay.FontSize = 18ElseIf optfont24.Value = 24 Thenlbldisplay.FontSize = 24ElseIf optfont36.Value = True Then
lbldisplay.FontSize = 36End If
'setting colourIf optblack.Value = True Thenlbldisplay.ForeColor = vbBlacktxtname.ForeColor = vbBlackEnd IfIf optblue.Value = True Thenlbldisplay.ForeColor = vbBluetxtname.ForeColor = vbBlue
End IfIf optgreen.Value = True Thenlbldisplay.ForeColor = vbGreentxtname.ForeColor = vbGreenEnd IfIf optred.Value = True Thenlbldisplay.ForeColor = vbRedtxtname.ForeColor = vbRed
8/6/2019 Pracvb Printout-32 Pg
3/30
End If
End Sub
Private Sub Cmdexit_Click()EndEnd Sub
Output:-
PROGRAM 2:
Problem Statement:
Write a project to display the flags of four differentcountries, depending on the setting of the option buttons.In addition, display the name of the country in the largelabel under the flag image. The user can also choose todisplay or hide the forms title, the country name, and thename of the programmer. Use check boxes for thedisplay/hide choices.
Include keyboard access keys for all option buttons,check boxes, and command buttons. Also include ToolTips forthe command buttons.
8/6/2019 Pracvb Printout-32 Pg
4/30
Code Window:-
Private Sub cmdexit_Click()EndEnd Sub
Private Sub cmdshow_Click()imgdisplay.Visible = TrueIf optindia.Value = True Thenlblcountryname.Caption = "India"imgdisplay.Picture = imgindia.PictureElseIf optusa.Value = True Thenlblcountryname.Caption = "USA"imgdisplay.Picture = imgusa.PictureElseIf optjapan.Value = True Thenlblcountryname.Caption = "JAPAN"imgdisplay.Picture = imgjapan.PictureElseIf optcanada.Value = True Thenlblcountryname.Caption = "CANADA"imgdisplay.Picture = imgcanada.PictureEnd If
If chktitle.Value = 0 Thenlbltitle.Visible = FalseElseIf chktitle.Value = 1 Thenlbltitle.Visible = TrueEnd If
If chkcountryname.Value = 0 Thenlblcountryname.Visible = FalseElseIf chkcountryname.Value = 1 Thenlblcountryname.Visible = TrueEnd IfIf chkprogrammer.Value = 0 Thenlblpgm.Visible = FalseElseIf chkprogrammer.Value = 1 Thenlblpgm.Visible = TrueEnd If
End Sub
8/6/2019 Pracvb Printout-32 Pg
5/30
Output:-
PROGRAM 3:
Problem Statement:
Create a project for R n R for Reading n Refreshmentthat calculates the amount due for individual orders andmaintains accumulated totals for a summary. Have a checkbox for Takeout items, which are taxable (8 percent); allothers are nontaxable. Include option buttons for the fiverefreshing drinks selection Tea, Coffee, Pepsi, Thums Up,
and Limca. The prices for each will be assigned using theseconstants:
Tea 10Coffee 20Pepsi 15Thums Up 15
8/6/2019 Pracvb Printout-32 Pg
6/30
Limca 15
Use a command button for Calculate Selection, whichwill calculate and display the amount due for each item. Abutton for Clear for Next Item will clear the selectionsand amount for the single item. Additional labels in aseparate frame will maintain the summary information forthe current order to include subtotal, tax, and total.
Buttons at the bottom of the form will be used for NewOrder, Summary, and Exit. The New Order button will clearthe bill for the current customer and add to the totals forthe summary. The button for Summary should display theaverage sale amount per customer and the number ofcustomers in a message box.
Code window:-
Option ExplicitDim mcurSubtotal As CurrencyDim mcurtotal As CurrencyDim mcurgrandtotal As CurrencyDim mintCustomercount As Integer
Private Sub cmdcalculate_Click()' calculate and display the current amountsDim curPrice As CurrencyDim intQuantity As IntegerDim curTax As CurrencyDim curItemamount As CurrencyConst curTaxRate As Currency = 0.08Const curtea As Currency = 10Const curcoffee As Currency = 12.25Const curpepsi As Currency = 20Const curcocacola As Currency = 22Const curlimca As Currency = 21.5'find the priceIf opttea.Value = True ThencurPrice = curteaElseIf optcoffee.Value = True ThencurPrice = curcoffeeElseIf optpepsi.Value = True ThencurPrice = curpepsiElseIf optcocacola.Value = True ThencurPrice = curcocacolaElseIf optlimca.Value = True ThencurPrice = curlimcaEnd If
' add the price times qty to the price so far
8/6/2019 Pracvb Printout-32 Pg
7/30
If IsNumeric(txtquantity.Text) ThenintQuantity = Val(txtquantity.Text)curItemamount = curPrice * intQuantitymcurSubtotal = mcurSubtotal + curItemamountIf chktax.Value = Checked Then
curTax = mcurSubtotal + curTaxRateEnd Ifmcurtotal = mcurSubtotal + curTaxlblitemamount.Caption = FormatCurrency(curItemamount)lblsubtotal.Caption = FormatNumber(mcurSubtotal)lbltax.Caption = FormatNumber(curTax)
lbltotal.Caption = FormatCurrency(mcurtotal)ElseMsgBox "quantity must be numeric", vbExclamation, "numeric test"txtquantity.SetFocusEnd If
End Sub
Private Sub cmdclear_Click()'clear the controlsIf mcurSubtotal 0 Thenopttea.Value = Trueoptcoffee.Value = Falseoptpepsi.Value = Falseoptcocacola.Value = Falseoptlimca.Value = Falselblitemamount.Caption = " "chktax.Enabled = True
With txtquantity.Text = " ".SetFocusEnd WithElseMsgBox "no new order to clear", vbExclamation, "customer order"End If
End Sub
Private Sub cmdexit_Click()
End
End Sub
Private Sub cmdneworder_Click()'clrar the current order and add to totalscmdclear_Clicklblsubtotal.Caption = ""
8/6/2019 Pracvb Printout-32 Pg
8/30
lbltax.Caption = ""lbltotal.Caption = ""'add to totalsIf mcurSubtotal 0 Thenmcurgrandtotal = mcurgrandtotal + mcurtotalmcurSubtotal = 0mcurtotal = 0mintCustomercount = mintCustomercount + 1End IfWith chktax
.Enabled = True
.Value = UncheckedEnd With
End Sub
Private Sub cmdsummary_Click()'calculate the average and display the totalsDim curAverage As CurrencyDim strMessagestring As StringDim strFormattedavg As StringIf mintCustomercount > 0 ThenIf mcurtotal 0 Thencmdneworder_ClickEnd IfcurAverage = mcurgrandtotal / mintCustomercount'format the numbersstrFormattedavg = FormatCurrency(curAverage)'concatenate the messagestringstrMessagestring = "number orders:" & mintCustomercount & vbCrLf & _
"average sale:" & strFormattedavg
MsgBox strMessagestring, vbInformation, "sales summary"ElseMsgBox "no data to summarize", vbExclamation, "sales summary"End If
End Sub
Output:-
8/6/2019 Pracvb Printout-32 Pg
9/30
PROGRAM 4:
Problem Statement:
Piecework workers are paid on the basis of piece. Workerswho produce a greater quantity of output are often paid ata higher rate.
Form: Use text boxes to obtain the persons name and thenumber of pieces completed. Include a Calculate commandbutton to display the dollar amount earned. You will need aSummary button to display the total number of pieces, thetotal pay, and the average pay per person. A clear buttonshould clear the name and the number of pieces for thecurrent employee.
Include validation to check for missing data. If theuser clicks on the Calculate button without first enteringa name and number of pieces, display a message box. Also,you need to make sure to not display a summary before anydata are entered; you cannot calculate an average when noitems have been calculated. You can check the number ofemployees in the Summary event procedure or disable theSummary command button until the first order has beencalculated.
Pieces Completed Price Paid per Piece for allPieces
8/6/2019 Pracvb Printout-32 Pg
10/30
1-199 0.50200-399 0.55400-599 0.60600 or more 0.65
Code Window:-Option Explicit
Dim mpieces As IntegerDim mtotalamount As CurrencyDim mworkers As IntegerDim currentamount As Currency
Private Sub cmdcalculate_Click()Const rate1 As Currency = 0.5Const rate2 As Currency = 0.55Const rate3 As Currency = 0.6Const rate4 As Currency = 0.66Dim pieces As Integer
Dim wages As Currency
If txtname.Text " " ThenIf txtnumber.Text " " ThenIf IsNumeric(txtnumber.Text) Then
pieces = Val(txtnumber.Text)If pieces >= 1 And pieces = 200 And pieces = 400 And pieces = 600 Thenwages = rate4ElseMsgBox " numeric data expected", vbExclamation, "data error"End IfEnd IfEnd IfEnd If'calculate the current wagescurrentamount = pieces * wages
txtdisplay.Text = FormatCurrency(currentamount)End Sub
Private Sub cmdclear_Click()If currentamount 0 Then
txtname.Text = ""txtnumber.Text = ""txtdisplay.Text = ""
8/6/2019 Pracvb Printout-32 Pg
11/30
txtname.SetFocus'Else'MsgBox " no data to clear", vbInformation, "data clear"End IfIf currentamount 0 Thenmtotalamount = mtotalamount + currentamounttxttotalvalue.Text = mtotalamountcurrentamount = 0mpieces = mpieces + 1txtpieces.Text = mpiecesmworkers = mworkers + 1txtworkers.Text = mworkersEnd IfEnd SubPrivate Sub cmdexit_Click()EndEnd SubPrivate Sub cmdsummary_Click()'calculate the average and display the totalsDim curAverage As CurrencyDim strMessage As StringDim strFormattedavg As StringIf mpieces > 0 ThenIf mtotalamount 0 Thencmdclear_ClickEnd IfcurAverage = mtotalamount \ mworkersstrFormattedavg = FormatCurrency(curAverage)strMessage = "no of workers" & mworkers & vbCrLf & _
"average amount earned" & strFormattedavgMsgBox strMessage, vbInformation, "pieces workers summary"
ElseMsgBox "no data to summarize", vbExclamation, "pieces workers summary"End IfEnd Sub
Output:-
8/6/2019 Pracvb Printout-32 Pg
12/30
Program No:5
Problem Statement:
A salesperson earns a weekly base salary plus a commissionwhen sales are at or above quota. Create a project thatallows the user to input the weekly sales and the
salesperson name, calculates the commission, and displayssummary information.
Form: The form will have text boxes for the salespersonname and his or her weekly sales.
Menu:
File Edit HelpPay Clear AboutSummary -------Exit Font
ColorUse constants to establish the base pay, the quota, and thecommission rate.
The Pay menu command calculates and displays in labelsthe commission and the total pay for that person. However,if there is no commission, do not display the commissionamount (do not display a zero-commission amount).
8/6/2019 Pracvb Printout-32 Pg
13/30
Use a function procedure to calculate the commission.The function must compare sale to quota. When the sales areequal to or greater than the quota, calculate thecommission by the commission rate.
Each salesperson receives the base pay plus thecommission (if one has been earned). Format the dollaramounts to two decimal places; do not use a dollar sign.
The Summary menu command displays a message boxcontaining total sales, total commissions, and total pay
for all salespersons. Display the numbers with two decimalplaces and dollar signs.
The Clear menu command clears the name, sales, and payfor the current employee and then rests the focus.
The Color and Font menu commands should change thecolor and font of the information displayed in the amountearned label.
Se a message box to display your name as programmerfor the About option on the Help menu.
Quota=1000; Commission Rate=0.15 and Base Pay=250
Code Window:-
Option ExplicitConst mbasepay = 250Const mquota = 1000Const mrate = 0.15
Dim mgrandtotal As CurrencyDim mtotalsales As Currency
Dim mtotalcommission As Currency
Private Function commission(ByVal mrate As Currency, sales As Currency)If sales >= mquota Thencommission = mrate * saleslblcommission.Caption = commissionElsecommission = 0End Ifmtotalcommission = mtotalcommission + commissionEnd Function
Private Sub cmdexit_Click()
EndEnd Sub
Private Sub mnuabout_Click()Dim message As String
8/6/2019 Pracvb Printout-32 Pg
14/30
message = "programmed by vandana"MsgBox message, vbInformation, "programmer details"
End Sub
Private Sub mnuclear_Click()txtname.Text = " "txtsales.Text = ""lblcommission.Caption = " "lbltotalsalary.Caption = " "txtname.SetFocusEnd Sub
Private Sub mnucolor_Click()lbltotalsalary.ForeColor = vbRed
End Sub
Private Sub mnuexit_Click()EndEnd Sub
Private Sub mnufont_Click()lbltotalsalary.FontSize = 14lbltotalsalary.Font.Bold = True
End Sub
Private Sub mnupay_Click()Dim sales As CurrencyDim totalamount As Currency
sales = Val(txtsales.Text)If sales 0 Thentotalamount = mbasepay + commission(mrate, sales)lbltotalsalary.Caption = totalamountmgrandtotal = mgrandtotal + totalamountmtotalsales = mtotalsales + salesEnd If
End Sub
Private Sub mnusummary_Click()
Dim sumsales As CurrencyDim sumpay As CurrencyDim sumcommission As Currencysumsales = FormatCurrency(mtotalsales, 2)sumcommission = FormatCurrency(mtotalcommission, 2)sumpay = FormatCurrency(mgrandtotal, 2)Dim strmsg As String
8/6/2019 Pracvb Printout-32 Pg
15/30
strmsg = " total sales is" & sumsales & vbCrLf & _"total commission is" & sumcommission & vbCrLf & _"total pay earned " & sumpay
MsgBox strmsg, vbInformation, "summary information"End Sub
Output:-
Program No:6
Problem Statement:
Create a project that will produce a summary of the amountsdue for Pats Auto Repair Shop. Display a splash screenfirst; then display the main form.
8/6/2019 Pracvb Printout-32 Pg
16/30
The main form menus:
File Process HelpExit Job Information About
Job Information form:Information form must have text boxes for the user to
enter the job number, customer name, amount charged forparts, and the hours of labor. Include labels for Parts,
Labor, SubTotal, Sales Tax, and Total.Include command buttons for Calculate, Print, Clear,
and OK.The Calculate button finds the charges and displays
them in labels. The tax rate and the hourly labor chargeshould be set up as named constants so that they can beeasily modified if either changes. Current charges are $30per hour for labor and 8 percent (0.08) for the sales taxrate. Sales Tax is charged only on parts, not on labor.
The Print button prints the current form.The Clear button clears the text boxes and labels and
resets the focus in the first text box.The OK button hides the Job information form and
displays the main form.
Code Window:-frmSplash
Option ExplicitPrivate Sub Form_KeyPress(KeyAscii As Integer)
Unload MeFrmsummary.Show
End Sub
Private Sub Frame1_Click()Unload MeFrmsummary.Show
End Sub
frmSummary
Private Sub mnuabout_Click()MsgBox "programmed by vandana", vbOKOnly, "programmerinformation"End Sub
Private Sub mnuexit_Click()EndEnd Sub
8/6/2019 Pracvb Printout-32 Pg
17/30
Private Sub mnujobinformation_Click()Unload Mefrminformation.ShowEnd Sub
frmInformation
Option ExplicitConst labourcost As Currency = 30Const salestax As Currency = 0.08
Private Sub cmdcalculate_Click()Dim parts As IntegerDim labourhrs As IntegerDim labourcharges As CurrencyDim partscost As CurrencyDim subtotal As CurrencyDim total As Currency
Dim tax As Currencyparts = Val(txtparts.Text)labourhrs = Val(txthours.Text)labourcharges = labourcost * labourhrspartscost = partstax = salestax * partssubtotal = partscost + labourchargestotal = subtotal + taxlblpartscharges.Caption = FormatCurrency(partscost)lbllabourcharges.Caption = FormatCurrency(labourcharges)lbltax.Caption = FormatCurrency(tax)
lblsubtotal.Caption = FormatCurrency(subtotal)lbltotal.Caption = FormatCurrency(total)End Sub
Private Sub cmdclear_Click()txtjobnumber.Text = " "txtname.Text = " "txtparts.Text = " "txthours.Text = " "lblpartscharges.Caption = " "
lbltax.Caption = " "lbllabourcharges.Caption = " "lblsubtotal.Caption = " "lbltotal.Caption = " "End Sub
Private Sub cmdok_Click()Unload Me
8/6/2019 Pracvb Printout-32 Pg
18/30
Frmsummary.ShowEnd Sub
Program NO.:7
Problem Statement:
8/6/2019 Pracvb Printout-32 Pg
19/30
Generate mailing labels with an account number for catalogsubscriptions. The project will allow the user to enterLast Name, First Name, Street, City, State, Zip Code, andExpiration Date for the subscription. A dropdown list boxwill contain the names of the catalogs: Odds and Ends,Solutions, Camping Needs, ToolTime , Spiegel, The Outlet,and The Large Size.
Use validation to make sure that entries appear in theLast Name, Zip Code, and Expiration Date fields.
The account number will consist of the first twocharacters of the Last Name, the first three digits of theZip Code, and the Expiration Date. Display the accountnumber in a label on the form when the user clicks on theDisplay Account Number button or menu option.
The menu or command buttons for the project shouldhave options for Print Label, Display Account Number, Exit,and Clear.
The Print Label menu command will print the labelusing the following format:
First Name Last Name Account NumberStreetCity, Zip Code
Code Window:-
Private Sub cmdclear_Click()txtfristname.Text = ""txtlastname.Text = " "
txtstreet.Text = " "txtcity.Text = " "txtzipcode.Text = " "txtstate.Text = " "txtexpdate.Text = " "lblaccnumber.Caption = " "End Sub
Private Sub cmddisplay_Click()Dim lastname As StringDim zipcode As String
Dim expdate As StringIf txtlastname.Text " " And txtzipcode.Text "" And txtexpdate.Text " "Thenlastname = txtlastname.Text
zipcode = txtzipcode.Textexpdate = txtexpdate.TextDim accnumber As StringDim str1 As String
8/6/2019 Pracvb Printout-32 Pg
20/30
Dim str2 As Stringstr1 = Left(lastname, 2)str2 = Left(zipcode, 3)accnumber = str1 & str2 & txtexpdate.Textlblaccnumber.Caption = accnumber
ElseMsgBox "values missing", vbOKOnly, "missing values"
End IfEnd Sub
Private Sub cmdexit_Click()EndEnd Sub
Private Sub cmdprint_Click()Printer.Print txtfirstname.Text; txtlastname.Text, lblaccnumber.CaptionPrinter.Print txtstreet.TextPrinter.Print txtcity.Text, txtzipcode.TextEnd Sub
Private Sub mnuclear_Click()cmdclear_ClickEnd Sub
Private Sub mnudisplay_Click()cmddisplay_ClickEnd Sub
Private Sub mnuexit_Click()cmdexit_ClickEnd Sub
Private Sub mnuprint_Click()cmdprint_ClickEnd Sub
Output:-
8/6/2019 Pracvb Printout-32 Pg
21/30
Program no 8
Create a project for R n R for reading and Refreshment that determines the price
per pound for bulk coffee sales. The coffees are divided into categories regular,decaf and special blend. The prices are set by pound, pound and fullpound. Use a find price command button to search for the appropriate pricebased on the selections.
Regular Decaf Blend pound 2.60 2.90 3.25 pound 4.90 5.60 6.10
8/6/2019 Pracvb Printout-32 Pg
22/30
full pound 8.75 9.75 11.25
Create a user defined data type that contains the coffee type, amount and price.Set up a variable called mudt Transaction i.e. an array of 20 elements of yourdata type. Each time the Find Price button is pressed, add the data to the array.
CODE WINDOW:
Option ExplicitDim mcurPrice(0 To 2, 0 To 2) As Currency
Private Type CoffeeSalestrType As StringstrQuantity As StringcurPrice As CurrencyEnd Type
Dim mudtTransaction(20) As CoffeeSale
Dim mintNumberTransactions As IntegerDim mlngWeight As Long
Private Sub cmdClear_Click()'Remove the selection from the lists ands clear the price
Dim intIndex As IntegercboType.ListIndex = -1 'clear selectionlblPrice.Caption = ""mlngWeight = 0For intIndex = 0 To 2
optWeight(intIndex).Value = FalseNext intIndexEnd Sub
Private Sub cmdExit_Click()'Print report and terminate the projectDim intIndex As IntegerDim strPrintPrice As StringPrinter.Print Tab(45); "sales report"Printer.Print ""
For intIndex = 0 To mintNumberTransactions - 1strPrintPrice = FormatCurrency(mudtTransaction(intIndex).curPrice)Printer.Print Tab(10); mudtTransaction(intIndex).strType; _Tab(35); mudtTransaction(intIndex).strQuantity; _Tab(65 - Len(strPrintPrice)); strPrintPriceNext intIndexEndEnd Sub
8/6/2019 Pracvb Printout-32 Pg
23/30
Private Sub cmdFindPrice_Click()'look up the price using the quantity and typeDim intRow As IntegerDim intCol As IntegerDim curPrice As CurrencyintRow = mlngWeightIf mintNumberTransactions
8/6/2019 Pracvb Printout-32 Pg
24/30
Private Sub optWeight_Click(Index As Integer)'find the selected weightmlngWeight = IndexEnd Sub
OUTPUT:
PROGRAM 9:
Problem Statement:
(Two-dimensional table) Create a project that looks up thedriving distance between two cities. Label one list asDeparture and the other as Destination. Use a commandbutton to calculate distance.
Boston Chicago Dallas Las
Vegas
Los
Angeles
Boston 0 1004 1753 2752 3017Chicago 1004 0 921 1780 2048Dallas 1753 921 0 1230 1399Las
Vegas2752 1780 1230 0 272
LosAngeles
3017 2048 1399 272 0
CODE WINDOW:
8/6/2019 Pracvb Printout-32 Pg
25/30
Option ExplicitDim mintdistance(0 To 4, 0 To 4) As IntegerDim mintDep As IntegerDim mintDest As Integer
Private Sub cmdClear_Click()lstDeparture = -1lstDestination = -1lblDistance = ""mintDest = 0mintDep = 0End Sub
Private Sub cmdExit_Click()EndEnd Sub
Private Sub Form_Load()mintdistance(0, 0) = 0mintdistance(0, 1) = 1004mintdistance(0, 2) = 1753mintdistance(0, 3) = 2752mintdistance(0, 4) = 3017mintdistance(1, 0) = 1004mintdistance(1, 1) = 0mintdistance(1, 2) = 921mintdistance(1, 3) = 1780mintdistance(1, 4) = 2048mintdistance(2, 0) = 1753mintdistance(2, 1) = 921mintdistance(2, 2) = 0
mintdistance(2, 3) = 1230mintdistance(2, 4) = 1399mintdistance(3, 0) = 2752mintdistance(3, 1) = 1780mintdistance(3, 2) = 1230mintdistance(3, 3) = 0mintdistance(3, 4) = 272mintdistance(4, 0) = 3017mintdistance(4, 1) = 2048mintdistance(4, 2) = 1399mintdistance(4, 3) = 272
mintdistance(4, 4) = 0End Sub
Private Sub cmdCalculate_Click()mintDep = lstDeparture.ListIndexmintDest = lstDestination.ListIndexIf mintDep -1 And mintDest -1 Then
8/6/2019 Pracvb Printout-32 Pg
26/30
lblDistance.Caption = mintdistance(mintDep, mintDest)ElseMsgBox "select cities", vbOKOnly, "Error"End IfEnd Sub
OUTPUT:
Program 10Create and maintain a database to keep track of books for R n R for reading andrefreshment .This project displays all the options available with databases.
Code window:Private Sub cmdAdd_Click()
'Add a new recordIf cmdAdd.Caption = "&Add" Then
datBooks.Recordset.AddNew 'clear out fields for new recordtxtISBN.SetFocusDisableButtons 'Disable navigationcmdSave.Enabled = True 'Enable the Save ButtoncmdAdd.Caption = "&Cancel" 'allow a cancel option
ElsedatBooks.Recordset.CancelUpdate 'Cancel the addEnableButtons 'enable navigation
cmdSave.Enabled = False 'disable the save buttoncmdAdd.Caption = "&Add" 'reset the add button
End IfEnd Sub
Private Sub cmdDelete_Click()'delete the current recordWith datBooks.Recordset
8/6/2019 Pracvb Printout-32 Pg
27/30
.Delete 'delete the current record
.MoveNext 'move to the following recordIf .EOF Then 'if last record deleted
.MovePreviousIf .BOF Then 'if BOF and EOF true,no records remain
MsgBox "The Recordset id empty.", vbInformation, "No records"DisableButtonsEnd If
End IfEnd With
End Sub
Private Sub cmdFirst_Click()'move to first recorddatBooks.Recordset.MoveFirst
End SubPrivate Sub cmdLast_Click()
'move to last recorddatBooks.Recordset.MoveLas
End SubPrivate Sub cmdNext_Click()
'move to next recordWith datBooks.Recordset
.MoveNextIf .EOF Then
.MoveFirstEnd If
End WithEnd Sub
Private Sub cmdPrevious_Click()
'move to previous recordWith datBooks.Recordset
.MovePreviousIf .BOF Then.MoveLastEnd If
End WithEnd Sub
Private Sub cmdSave_Click()' save the current recorddatBooks.Recordset.Update
EnableButtonscmdSave.Enabled = FalsecmdAdd.Caption = "&Add"End Sub
Private Sub mnuFileExit_Click()'exit the projectEndEnd Sub
8/6/2019 Pracvb Printout-32 Pg
28/30
Private Sub DisableButtons()'disable navigation buttonscmdNext.Enabled = FalsecmdPrevious.Enabled = FalsecmdFirst.Enabled = FalsecmdLast.Enabled = FalsecmdDelete.Enabled = FalseEnd Sub
Private Sub EnableButtons()'enable navigation buttonscmdNext.Enabled = TruecmdPrevious.Enabled = TruecmdFirst.Enabled = TruecmdLast.Enabled = TruecmdDelete.Enabled = TrueEnd Sub
OUTPUT:
8/6/2019 Pracvb Printout-32 Pg
29/30
Program 11:
(General declaration )Private Sub cmdAdd_Click()If cboColleges.Text "" Then
With cboColleges.AddItem .Text
.Text = ""End WithElseMsgBox "Add a College name", vbExclamation, "Missing data"End IfcboColleges.SetFocus
End Sub
Private Sub cmdOk_Click()txtName.Text = ""txtUnits.Text = ""
optFirst.Value = FalseoptSecond.Value = FalseoptThird.Value = False
End Sub
Private Sub cmdPrint_Click()If cboColleges.ListIndex -1 And lstSchools.ListIndex -1 Then
Printer.PrintIf txtName.Text = "" And txtUnits.Text = "" Then
MsgBox "Enter the data", vbExclamation, "Missing data"Else
Printer.Print Tab(15); "Name:"; txtName.TextPrinter.Print Tab(15); "Units:"; txtUnits.TextPrinter.Print
End IfIf optFirst.Value = True Then
Printer.Print Tab(15); "First Year"ElseIf optSecond.Value = True ThenPrinter.Print Tab(15); "Second Year"
ElsePrinter.Print Tab(15); "Third Year"End If
Printer.PrintPrinter.Print Tab(15); "SCHOOLS"Printer.PrintPrinter.Print Tab(10); "College:"; cboColleges.TextPrinter.PrintPrinter.Print Tab(10); "Department:"; lstSchools.TextPrinter.PrintPrinter.Print Tab(10); " Dean List :"; lstDean.Text
8/6/2019 Pracvb Printout-32 Pg
30/30
Printer.EndDocElse
MsgBox "Make a selection for colleges and department", vbExclamation,"Missing Data"
End IfEnd Sub
Private Sub mnuFilePrintSchools_Click()Dim intIndex As IntegerDim intFinalValue As IntegerPrinter.Print 'Blank Line
Printer.Print Tab(20); "Schools"Printer.Print 'BlankintFinalValue = cboColleges.ListCount - 1'List index starts at zeroFor intIndex = 0 To intFinalValuePrinter.Print Tab(20); cboColleges.List(intIndex)Next intIndexPrinter.EndDocEnd Sub
Private Sub mnuHelpAbout_Click()MsgBox "Programmed By :Poonam and Prajakta", vbInformation
End Sub
Private Sub mnuFileExit_Click()End
End Sub
Output: