Pracvb Printout-32 PG
Pracvb Printout-32 PG
Create four frames which allow the user to choose Color Font Styles Font Size Languages Include a label which will display Hello World in four different languages English Spanish French Italian, depending on the users choice. Include Display, Clear and Exit command buttons. When the user clicks on the Display command button, the respective Color, 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 = False End With lbldisplay.Caption = " " End Sub Private Sub Cmddisplay_Click() 'setting styles If chkbold.Value = 1 Then lbldisplay.Font.Bold = True txtname.Font.Bold = True ElseIf chkbold.Value = 0 Then lbldisplay.Font.Bold = False txtname.Font.Bold = False End If If chkitalic.Value = 1 Then
lbldisplay.Font.Italic = True txtname.Font.Italic = True ElseIf chkitalic.Value = 0 Then lbldisplay.Font.Italic = False txtname.Font.Italic = False End If If chkunderline.Value = 1 Then lbldisplay.Font.Underline = True txtname.Font.Underline = True ElseIf chkunderline.Value = 0 Then lbldisplay.Font.Underline = False txtname.Font.Underline = False End If 'setting language If optenglish.Value = True Then lbldisplay.Caption = " Hello world" ElseIf optfrench.Value = True Then lbldisplay.Caption = " Bonjour tout le monde" ElseIf optitalian.Value = True Then lbldisplay.Caption = " Ciao Mondo " ElseIf optspanish.Value = True Then lbldisplay.Caption = " Hola Mundo" End If 'setting fontsize If optfont18.Value = True Then lbldisplay.FontSize = 18 ElseIf optfont24.Value = 24 Then lbldisplay.FontSize = 24 ElseIf optfont36.Value = True Then lbldisplay.FontSize = 36 End If 'setting colour If optblack.Value = True Then lbldisplay.ForeColor = vbBlack txtname.ForeColor = vbBlack End If If optblue.Value = True Then lbldisplay.ForeColor = vbBlue txtname.ForeColor = vbBlue End If If optgreen.Value = True Then lbldisplay.ForeColor = vbGreen txtname.ForeColor = vbGreen End If If optred.Value = True Then lbldisplay.ForeColor = vbRed txtname.ForeColor = vbRed
Output:-
PROGRAM 2: Problem Statement: Write a project to display the flags of four different countries, depending on the setting of the option buttons. In addition, display the name of the country in the large label under the flag image. The user can also choose to display or hide the forms title, the country name, and the name of the programmer. Use check boxes for the display/hide choices. Include keyboard access keys for all option buttons, check boxes, and command buttons. Also include ToolTips for the command buttons.
Code Window:Private Sub cmdexit_Click() End End Sub Private Sub cmdshow_Click() imgdisplay.Visible = True If optindia.Value = True Then lblcountryname.Caption = "India" imgdisplay.Picture = imgindia.Picture ElseIf optusa.Value = True Then lblcountryname.Caption = "USA" imgdisplay.Picture = imgusa.Picture ElseIf optjapan.Value = True Then lblcountryname.Caption = "JAPAN" imgdisplay.Picture = imgjapan.Picture ElseIf optcanada.Value = True Then lblcountryname.Caption = "CANADA" imgdisplay.Picture = imgcanada.Picture End If If chktitle.Value = 0 Then lbltitle.Visible = False ElseIf chktitle.Value = 1 Then lbltitle.Visible = True End If If chkcountryname.Value = 0 Then lblcountryname.Visible = False ElseIf chkcountryname.Value = 1 Then lblcountryname.Visible = True End If If chkprogrammer.Value = 0 Then lblpgm.Visible = False ElseIf chkprogrammer.Value = 1 Then lblpgm.Visible = True End If End Sub
Output:-
PROGRAM 3: Problem Statement: Create a project for R n R for Reading n Refreshment that calculates the amount due for individual orders and maintains accumulated totals for a summary. Have a check box for Takeout items, which are taxable (8 percent); all others are nontaxable. Include option buttons for the five refreshing drinks selection Tea, Coffee, Pepsi, Thums Up, and Limca. The prices for each will be assigned using these constants: Tea Coffee Pepsi Thums Up 10 20 15 15
Limca
15
Use a command button for Calculate Selection, which will calculate and display the amount due for each item. A button for Clear for Next Item will clear the selections and amount for the single item. Additional labels in a separate frame will maintain the summary information for the current order to include subtotal, tax, and total. Buttons at the bottom of the form will be used for New Order, Summary, and Exit. The New Order button will clear the bill for the current customer and add to the totals for the summary. The button for Summary should display the average sale amount per customer and the number of customers in a message box.
Code window:Option Explicit Dim mcurSubtotal As Currency Dim mcurtotal As Currency Dim mcurgrandtotal As Currency Dim mintCustomercount As Integer Private Sub cmdcalculate_Click() ' calculate and display the current amounts Dim curPrice As Currency Dim intQuantity As Integer Dim curTax As Currency Dim curItemamount As Currency Const curTaxRate As Currency = 0.08 Const curtea As Currency = 10 Const curcoffee As Currency = 12.25 Const curpepsi As Currency = 20 Const curcocacola As Currency = 22 Const curlimca As Currency = 21.5 'find the price If opttea.Value = True Then curPrice = curtea ElseIf optcoffee.Value = True Then curPrice = curcoffee ElseIf optpepsi.Value = True Then curPrice = curpepsi ElseIf optcocacola.Value = True Then curPrice = curcocacola ElseIf optlimca.Value = True Then curPrice = curlimca End If ' add the price times qty to the price so far
If IsNumeric(txtquantity.Text) Then intQuantity = Val(txtquantity.Text) curItemamount = curPrice * intQuantity mcurSubtotal = mcurSubtotal + curItemamount If chktax.Value = Checked Then curTax = mcurSubtotal + curTaxRate End If mcurtotal = mcurSubtotal + curTax lblitemamount.Caption = FormatCurrency(curItemamount) lblsubtotal.Caption = FormatNumber(mcurSubtotal) lbltax.Caption = FormatNumber(curTax) lbltotal.Caption = FormatCurrency(mcurtotal) Else MsgBox "quantity must be numeric", vbExclamation, "numeric test" txtquantity.SetFocus End If End Sub Private Sub cmdclear_Click() 'clear the controls If mcurSubtotal <> 0 Then opttea.Value = True optcoffee.Value = False optpepsi.Value = False optcocacola.Value = False optlimca.Value = False lblitemamount.Caption = " " chktax.Enabled = True With txtquantity .Text = " " .SetFocus End With Else MsgBox "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 totals cmdclear_Click lblsubtotal.Caption = ""
lbltax.Caption = "" lbltotal.Caption = "" 'add to totals If mcurSubtotal <> 0 Then mcurgrandtotal = mcurgrandtotal + mcurtotal mcurSubtotal = 0 mcurtotal = 0 mintCustomercount = mintCustomercount + 1 End If With chktax .Enabled = True .Value = Unchecked End With End Sub Private Sub cmdsummary_Click() 'calculate the average and display the totals Dim curAverage As Currency Dim strMessagestring As String Dim strFormattedavg As String If mintCustomercount > 0 Then If mcurtotal <> 0 Then cmdneworder_Click End If curAverage = mcurgrandtotal / mintCustomercount 'format the numbers strFormattedavg = FormatCurrency(curAverage) 'concatenate the messagestring strMessagestring = "number orders:" & mintCustomercount & vbCrLf & _ "average sale:" & strFormattedavg MsgBox strMessagestring, vbInformation, "sales summary" Else MsgBox "no data to summarize", vbExclamation, "sales summary" End If End Sub
Output:-
PROGRAM 4: Problem Statement: Piecework workers are paid on the basis of piece. Workers who produce a greater quantity of output are often paid at a higher rate. Form: Use text boxes to obtain the persons name and the number of pieces completed. Include a Calculate command button to display the dollar amount earned. You will need a Summary button to display the total number of pieces, the total pay, and the average pay per person. A clear button should clear the name and the number of pieces for the current employee. Include validation to check for missing data. If the user clicks on the Calculate button without first entering a name and number of pieces, display a message box. Also, you need to make sure to not display a summary before any data are entered; you cannot calculate an average when no items have been calculated. You can check the number of employees in the Summary event procedure or disable the Summary command button until the first order has been calculated. Pieces Completed Price Paid per Piece for all Pieces
Code Window:Option Explicit Dim mpieces As Integer Dim mtotalamount As Currency Dim mworkers As Integer Dim currentamount As Currency Private Sub cmdcalculate_Click() Const rate1 As Currency = 0.5 Const rate2 As Currency = 0.55 Const rate3 As Currency = 0.6 Const rate4 As Currency = 0.66 Dim pieces As Integer Dim wages As Currency If txtname.Text <> " " Then If txtnumber.Text <> " " Then If IsNumeric(txtnumber.Text) Then pieces = Val(txtnumber.Text) If pieces >= 1 And pieces <= 199 Then wages = rate1 ElseIf pieces >= 200 And pieces <= 399 Then wages = rate2 ElseIf pieces >= 400 And pieces <= 599 Then wages = rate3 ElseIf pieces >= 600 Then wages = rate4 Else MsgBox " numeric data expected", vbExclamation, "data error" End If End If End If End If 'calculate the current wages currentamount = pieces * wages txtdisplay.Text = FormatCurrency(currentamount) End Sub Private Sub cmdclear_Click() If currentamount <> 0 Then txtname.Text = "" txtnumber.Text = "" txtdisplay.Text = ""
txtname.SetFocus 'Else 'MsgBox " no data to clear", vbInformation, "data clear" End If If currentamount <> 0 Then mtotalamount = mtotalamount + currentamount txttotalvalue.Text = mtotalamount currentamount = 0 mpieces = mpieces + 1 txtpieces.Text = mpieces mworkers = mworkers + 1 txtworkers.Text = mworkers End If End Sub Private Sub cmdexit_Click() End End Sub Private Sub cmdsummary_Click() 'calculate the average and display the totals Dim curAverage As Currency Dim strMessage As String Dim strFormattedavg As String If mpieces > 0 Then If mtotalamount <> 0 Then cmdclear_Click End If curAverage = mtotalamount \ mworkers strFormattedavg = FormatCurrency(curAverage) strMessage = "no of workers" & mworkers & vbCrLf & _ "average amount earned" & strFormattedavg MsgBox strMessage, vbInformation, "pieces workers summary" Else MsgBox "no data to summarize", vbExclamation, "pieces workers summary" End If End Sub
Output:-
Program No:5
Problem Statement: A salesperson earns a weekly base salary plus a commission when sales are at or above quota. Create a project that allows the user to input the weekly sales and the salesperson name, calculates the commission, and displays summary information. Form: The form will have text boxes for the salesperson name and his or her weekly sales. Menu: File Pay Summary Exit Edit Help Clear About ------Font Color Use constants to establish the base pay, the quota, and the commission rate. The Pay menu command calculates and displays in labels the commission and the total pay for that person. However, if there is no commission, do not display the commission amount (do not display a zero-commission amount).
Use a function procedure to calculate the commission. The function must compare sale to quota. When the sales are equal to or greater than the quota, calculate the commission by the commission rate. Each salesperson receives the base pay plus the commission (if one has been earned). Format the dollar amounts to two decimal places; do not use a dollar sign. The Summary menu command displays a message box containing total sales, total commissions, and total pay for all salespersons. Display the numbers with two decimal places and dollar signs. The Clear menu command clears the name, sales, and pay for the current employee and then rests the focus. The Color and Font menu commands should change the color and font of the information displayed in the amount earned label. Se a message box to display your name as programmer for the About option on the Help menu. Quota=1000; Commission Rate=0.15 and Base Pay=250
Code Window:Option Explicit Const mbasepay = 250 Const mquota = 1000 Const mrate = 0.15 Dim mgrandtotal As Currency Dim mtotalsales As Currency Dim mtotalcommission As Currency Private Function commission(ByVal mrate As Currency, sales As Currency) If sales >= mquota Then commission = mrate * sales lblcommission.Caption = commission Else commission = 0 End If mtotalcommission = mtotalcommission + commission End Function Private Sub cmdexit_Click() End End Sub Private Sub mnuabout_Click() Dim message As String
message = "programmed by vandana" MsgBox message, vbInformation, "programmer details" End Sub Private Sub mnuclear_Click() txtname.Text = " " txtsales.Text = "" lblcommission.Caption = " " lbltotalsalary.Caption = " " txtname.SetFocus End Sub Private Sub mnucolor_Click() lbltotalsalary.ForeColor = vbRed End Sub Private Sub mnuexit_Click() End End Sub Private Sub mnufont_Click() lbltotalsalary.FontSize = 14 lbltotalsalary.Font.Bold = True End Sub Private Sub mnupay_Click() Dim sales As Currency Dim totalamount As Currency sales = Val(txtsales.Text) If sales <> 0 Then totalamount = mbasepay + commission(mrate, sales) lbltotalsalary.Caption = totalamount mgrandtotal = mgrandtotal + totalamount mtotalsales = mtotalsales + sales End If End Sub Private Sub mnusummary_Click() Dim sumsales As Currency Dim sumpay As Currency Dim sumcommission As Currency sumsales = FormatCurrency(mtotalsales, 2) sumcommission = FormatCurrency(mtotalcommission, 2) sumpay = FormatCurrency(mgrandtotal, 2) Dim strmsg As String
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 amounts due for Pats Auto Repair Shop. Display a splash screen first; then display the main form.
The main form menus: File Exit Process Job Information Help About
Job Information form: Information form must have text boxes for the user to enter the job number, customer name, amount charged for parts, 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 charge should be set up as named constants so that they can be easily modified if either changes. Current charges are $30 per hour for labor and 8 percent (0.08) for the sales tax rate. 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 Explicit Private Sub Form_KeyPress(KeyAscii As Integer) Unload Me Frmsummary.Show End Sub Private Sub Frame1_Click() Unload Me Frmsummary.Show End Sub
frmSummary
Private Sub mnuabout_Click() MsgBox "programmed by vandana", vbOKOnly, "programmer information" End Sub Private Sub mnuexit_Click() End End Sub
frmInformation
Option Explicit Const labourcost As Currency = 30 Const salestax As Currency = 0.08 Private Sub cmdcalculate_Click() Dim parts As Integer Dim labourhrs As Integer Dim labourcharges As Currency Dim partscost As Currency Dim subtotal As Currency Dim total As Currency Dim tax As Currency parts = Val(txtparts.Text) labourhrs = Val(txthours.Text) labourcharges = labourcost * labourhrs partscost = parts tax = salestax * parts subtotal = partscost + labourcharges total = subtotal + tax lblpartscharges.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
Program
NO.:7
Problem Statement:
Generate mailing labels with an account number for catalog subscriptions. The project will allow the user to enter Last Name, First Name, Street, City, State, Zip Code, and Expiration Date for the subscription. A dropdown list box will 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 the Last Name, Zip Code, and Expiration Date fields. The account number will consist of the first two characters of the Last Name, the first three digits of the Zip Code, and the Expiration Date. Display the account number in a label on the form when the user clicks on the Display Account Number button or menu option. The menu or command buttons for the project should have options for Print Label, Display Account Number, Exit, and Clear. The Print Label menu command will print the label using the following format: First Name Last Name Account Number Street City, 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 String Dim zipcode As String Dim expdate As String If txtlastname.Text <> " " And txtzipcode.Text <> "" And txtexpdate.Text <> " " Then lastname = txtlastname.Text zipcode = txtzipcode.Text expdate = txtexpdate.Text Dim accnumber As String Dim str1 As String
Dim str2 As String str1 = Left(lastname, 2) str2 = Left(zipcode, 3) accnumber = str1 & str2 & txtexpdate.Text lblaccnumber.Caption = accnumber Else MsgBox "values missing", vbOKOnly, "missing values" End If End Sub Private Sub cmdexit_Click() End End Sub Private Sub cmdprint_Click() Printer.Print txtfirstname.Text; txtlastname.Text, lblaccnumber.Caption Printer.Print txtstreet.Text Printer.Print txtcity.Text, txtzipcode.Text End Sub Private Sub mnuclear_Click() cmdclear_Click End Sub Private Sub mnudisplay_Click() cmddisplay_Click End Sub Private Sub mnuexit_Click() cmdexit_Click End Sub Private Sub mnuprint_Click() cmdprint_Click End Sub
Output:-
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 full pound. Use a find price command button to search for the appropriate price based on the selections. pound pound Regular 2.60 4.90 Decaf 2.90 5.60 Blend 3.25 6.10
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 your data type. Each time the Find Price button is pressed, add the data to the array.
CODE WINDOW:
Option Explicit Dim mcurPrice(0 To 2, 0 To 2) As Currency Private Type CoffeeSale strType As String strQuantity As String curPrice As Currency End Type Dim mudtTransaction(20) As CoffeeSale Dim mintNumberTransactions As Integer Dim mlngWeight As Long Private Sub cmdClear_Click() 'Remove the selection from the lists ands clear the price Dim intIndex As Integer cboType.ListIndex = -1 'clear selection lblPrice.Caption = "" mlngWeight = 0 For intIndex = 0 To 2 optWeight(intIndex).Value = False Next intIndex End Sub Private Sub cmdExit_Click() 'Print report and terminate the project Dim intIndex As Integer Dim strPrintPrice As String Printer.Print Tab(45); "sales report" Printer.Print "" For intIndex = 0 To mintNumberTransactions - 1 strPrintPrice = FormatCurrency(mudtTransaction(intIndex).curPrice) Printer.Print Tab(10); mudtTransaction(intIndex).strType; _ Tab(35); mudtTransaction(intIndex).strQuantity; _ Tab(65 - Len(strPrintPrice)); strPrintPrice Next intIndex End End Sub
Private Sub cmdFindPrice_Click() 'look up the price using the quantity and type Dim intRow As Integer Dim intCol As Integer Dim curPrice As Currency intRow = mlngWeight If mintNumberTransactions <= 20 Then 'allow only 20 transactions If cboType.ListIndex <> -1 Then intCol = cboType.ListIndex Select Case intRow Case 0 mudtTransaction(mintNumberTransactions).strQuantity = _ "quarter Pound" Case 1 mudtTransaction(mintNumberTransactions).strQuantity = _ "half pound" Case 2 mudtTransaction(mintNumberTransactions).strQuantity = _ "Full Pound" Case Else 'default to quarter pound mudtTransaction(mintNumberTransactions).strQuantity = _ "Quarter Pound" End Select curPrice = mcurPrice(intRow, intCol) lblPrice.Caption = FormatCurrency(curPrice) mudtTransaction(mintNumberTransactions).strType = _ cboType.List(intCol) mudtTransaction(mintNumberTransactions).curPrice = curPrice mintNumberTransactions = mintNumberTransactions + 1 Else MsgBox "select a type and quantity", vbExclamation, "entry Error" End If End If End Sub Private Sub form_load() 'load prices into the table mcurPrice(0, 0) = 2.6 mcurPrice(0, 1) = 2.9 mcurPrice(0, 2) = 3.25 mcurPrice(1, 0) = 4.9 mcurPrice(1, 1) = 5.6 mcurPrice(1, 2) = 6.1 mcurPrice(2, 0) = 8.75 mcurPrice(2, 1) = 9.75 mcurPrice(2, 2) = 11.25 End Sub
Private Sub optWeight_Click(Index As Integer) 'find the selected weight mlngWeight = Index End Sub
OUTPUT:
PROGRAM 9: Problem Statement: (Two-dimensional table) Create a project that looks up the driving distance between two cities. Label one list as Departure and the other as Destination. Use a command button to calculate distance. Boston Boston Chicago Dallas Las Vegas Los Angeles 0 1004 1753 2752 3017 Chicago 1004 0 921 1780 2048 Dallas 1753 921 0 1230 1399 Las Vegas 2752 1780 1230 0 272 Los Angeles 3017 2048 1399 272 0
CODE WINDOW:
Option Explicit Dim mintdistance(0 To 4, 0 To 4) As Integer Dim mintDep As Integer Dim mintDest As Integer Private Sub cmdClear_Click() lstDeparture = -1 lstDestination = -1 lblDistance = "" mintDest = 0 mintDep = 0 End Sub Private Sub cmdExit_Click() End End Sub Private Sub Form_Load() mintdistance(0, 0) = 0 mintdistance(0, 1) = 1004 mintdistance(0, 2) = 1753 mintdistance(0, 3) = 2752 mintdistance(0, 4) = 3017 mintdistance(1, 0) = 1004 mintdistance(1, 1) = 0 mintdistance(1, 2) = 921 mintdistance(1, 3) = 1780 mintdistance(1, 4) = 2048 mintdistance(2, 0) = 1753 mintdistance(2, 1) = 921 mintdistance(2, 2) = 0 mintdistance(2, 3) = 1230 mintdistance(2, 4) = 1399 mintdistance(3, 0) = 2752 mintdistance(3, 1) = 1780 mintdistance(3, 2) = 1230 mintdistance(3, 3) = 0 mintdistance(3, 4) = 272 mintdistance(4, 0) = 3017 mintdistance(4, 1) = 2048 mintdistance(4, 2) = 1399 mintdistance(4, 3) = 272 mintdistance(4, 4) = 0 End Sub Private Sub cmdCalculate_Click() mintDep = lstDeparture.ListIndex mintDest = lstDestination.ListIndex If mintDep <> -1 And mintDest <> -1 Then
lblDistance.Caption = mintdistance(mintDep, mintDest) Else MsgBox "select cities", vbOKOnly, "Error" End If End Sub
OUTPUT:
Program 10 Create and maintain a database to keep track of books for R n R for reading and refreshment .This project displays all the options available with databases.
Code window:
Private Sub cmdAdd_Click() 'Add a new record If cmdAdd.Caption = "&Add" Then datBooks.Recordset.AddNew 'clear out fields for new record txtISBN.SetFocus DisableButtons 'Disable navigation cmdSave.Enabled = True 'Enable the Save Button cmdAdd.Caption = "&Cancel" 'allow a cancel option Else datBooks.Recordset.CancelUpdate 'Cancel the add EnableButtons 'enable navigation cmdSave.Enabled = False 'disable the save button cmdAdd.Caption = "&Add" 'reset the add button End If End Sub Private Sub cmdDelete_Click() 'delete the current record With datBooks.Recordset
.Delete 'delete the current record .MoveNext 'move to the following record If .EOF Then 'if last record deleted .MovePrevious If .BOF Then 'if BOF and EOF true,no records remain MsgBox "The Recordset id empty.", vbInformation, "No records" DisableButtons End If End If End With End Sub Private Sub cmdFirst_Click() 'move to first record datBooks.Recordset.MoveFirst End Sub Private Sub cmdLast_Click() 'move to last record datBooks.Recordset.MoveLas End Sub Private Sub cmdNext_Click() 'move to next record With datBooks.Recordset .MoveNext If .EOF Then .MoveFirst End If End With End Sub Private Sub cmdPrevious_Click() 'move to previous record With datBooks.Recordset .MovePrevious If .BOF Then .MoveLast End If End With End Sub Private Sub cmdSave_Click() ' save the current record datBooks.Recordset.Update EnableButtons cmdSave.Enabled = False cmdAdd.Caption = "&Add" End Sub Private Sub mnuFileExit_Click() 'exit the project End End Sub
Private Sub DisableButtons() 'disable navigation buttons cmdNext.Enabled = False cmdPrevious.Enabled = False cmdFirst.Enabled = False cmdLast.Enabled = False cmdDelete.Enabled = False End Sub Private Sub EnableButtons() 'enable navigation buttons cmdNext.Enabled = True cmdPrevious.Enabled = True cmdFirst.Enabled = True cmdLast.Enabled = True cmdDelete.Enabled = True End Sub
OUTPUT:
Program 11:
(General declaration ) Private Sub cmdAdd_Click() If cboColleges.Text <> "" Then With cboColleges .AddItem .Text .Text = "" End With Else MsgBox "Add a College name", vbExclamation, "Missing data" End If cboColleges.SetFocus End Sub Private Sub cmdOk_Click() txtName.Text = "" txtUnits.Text = "" optFirst.Value = False optSecond.Value = False optThird.Value = False End Sub Private Sub cmdPrint_Click() If cboColleges.ListIndex <> -1 And lstSchools.ListIndex <> -1 Then Printer.Print If txtName.Text = "" And txtUnits.Text = "" Then MsgBox "Enter the data", vbExclamation, "Missing data" Else Printer.Print Tab(15); "Name:"; txtName.Text Printer.Print Tab(15); "Units:"; txtUnits.Text Printer.Print End If If optFirst.Value = True Then Printer.Print Tab(15); "First Year" ElseIf optSecond.Value = True Then Printer.Print Tab(15); "Second Year" Else Printer.Print Tab(15); "Third Year" End If Printer.Print Printer.Print Tab(15); "SCHOOLS" Printer.Print Printer.Print Tab(10); "College:"; cboColleges.Text Printer.Print Printer.Print Tab(10); "Department:"; lstSchools.Text Printer.Print Printer.Print Tab(10); " Dean List :"; lstDean.Text
Printer.EndDoc Else MsgBox "Make a selection for colleges and department", vbExclamation, "Missing Data" End If End Sub Private Sub mnuFilePrintSchools_Click() Dim intIndex As Integer Dim intFinalValue As Integer Printer.Print 'Blank Line Printer.Print Tab(20); "Schools" Printer.Print 'Blank intFinalValue = cboColleges.ListCount - 1 'List index starts at zero For intIndex = 0 To intFinalValue Printer.Print Tab(20); cboColleges.List(intIndex) Next intIndex Printer.EndDoc End Sub Private Sub mnuHelpAbout_Click() MsgBox "Programmed By :Poonam and Prajakta", vbInformation End Sub Private Sub mnuFileExit_Click() End End Sub
Output: