English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have to write a program that sells tickets at 10.00, chips @.75 nachos @2.25 drinks@1.50 and programs @5.00I have 5labels and 5 textboxes for each of the items above.The textboxes are to input the number of each items you want. we also have to calculate subtotal beforetax and then a subtotal with9% salestax.I have a command button for subtotal before sales tax and a command button for subtotal including tax.I also have two text boxes to display the results for each. As for the programming part,im not sure where to put my codes or even how to write the calculations.I think I have to put display somewhere to display the results and i know to use dim to declare variables.Im really not sure what i need to declare.I would assume the five things I am selling as strings I think with my command buttons i have to get them to add the totals of my textboxes, and the 2nd one to take the sum of the 5 and multiply by 1.09 for the sales tax. Cansome1 please help ive been struggling all year n this

2006-11-20 14:23:35 · 3 answers · asked by DuceDuce 2 in Computers & Internet Programming & Design

3 answers

Here's a few hints for you:

To make it easy: write a single Procedure that can be called multiple times from anywhere in the form. 1) to Calculate the total, and 2) to calculate the total with tax. Then you can call that from multiple places.

You know the prices for the items are fixed, so you have those numbers already. You just need to make sure the qty fields are valid. And you already learned how to validate a field, right?

Each field has a "depart" event, which is triggered when the cursor leaves that field. Each of the QTY field's "depart" should trigger the recalculation.

You can't multiply a string.

2006-11-20 14:31:14 · answer #1 · answered by Kasey C 7 · 0 0

you don't have to declare anything. first type "option explicit" at the top.. with that there it will tell you where your mistake is. then Dim all your variables. They should all be dimmed as integers becase no one will order 2.5 nachos haha you also need to have a variable for the subtotal and the answer, dim them both as a double.. make a variable for all 5 of the text boxes, like "Dim CHIPS as double"..
to make it easy, just type the following
Option explicit
Dim TICKETS as integer
Dim CHIPS as integer
Dim NACHOS as integer
Dim DRINKS as integer
Dim PROGRAMS as integer
Dim TOTAL as double
Dim SUBTOTAL as double
then go to the drop down list and click cmdSubtotal assuming you named your subtotal command button cmdSubtotal.. then type "CHIPS = txtChips" assuming you named your text box that people type in for the amount of chips "txtChips".. follow this example for all of them, then type
SUBTOTAL = (10 * TICKETS) + (0.75 * CHIPS) + (2.25* NACHOS) + (1.5 * DRINKS) + (5 * PROGRAMS)
actually it'll probably work without the brackets too

then type
lblSubtotal = "The cost before tax is " & SUBTOTAL
then go back to the drop down menu to cmdTotal, assuming you named your Total After Tax button "cmdTotal"
then type
TOTAL = SUBTOTAL * 1.09
lblTotal="The cost after tax is " & TOTAL
assuming you named your second label "lblTotal"
this is the easiest way i can think of to explain it.. if that doesnt work then im sorry haha i tried.. good luck!
oh if you want to make the answer rounded to two decimal places, that is possible but i dont remember how to do it.. i think its like
lblTotal="The cost after tax is " & Function(TOTAL, "####.00")
if that doesnt work then never mind haha

2006-11-20 14:51:10 · answer #2 · answered by .:*k i m*:. 1 · 0 0

i'm assuming that you want Sheet 2 to automobile replace in holding with what you replaced in Sheet1 on condition that the cells are proper to at least one yet another. I dont imagine you want to apply VBA code to achieve that. purely go with the cellular you want to automobile replace in Sheet 2 and then kind "=" and flow to sheet a million and choose the cellular you want or not that is referenced to and hit enter. Thats it. on each and every occasion the information is changed in sheet1, sheet2 will immediately away replace to the price. party: Sheet a million information is in A1 and sheet 2 is in A2. so that you kind this in Sheet 2: "=Sheet1!A2" the function is = keep on with by Sheet1 if u havent renamed the sheet or with singles quote if u did then said by ! and then the cellular. you may also do diverse cellular in case you want to combine them in a million cellular. enable say Sheet1 is now A1, A2, A3. so that you may want to do: =Sheet1!A1 & " " & Sheet1!A2 & " " Sheet1!A3 the & signal joins the texts mutually. i desire this allows you.

2016-11-29 08:02:46 · answer #3 · answered by ? 4 · 0 0

fedest.com, questions and answers