Any one good at Visual Basic??
Maybe i should jus toss it in the can, anywho, i am having a little trouble on how to get this part of my program to work, as usual.
This is the situation. I have a frame box which consists of 5 chkboxes. My question is how exactally would i go about adding each of the different chkbox values when they are checked
For instance:
(Bagel toppings)
Cream Cheese (.$50)
Butter ($.25)
Blueberry jam ($.75)
Raspberry jam ($.75)
Peach jelly ($.75)
If i click on any one or two or all of the following, how would i go about adding that value to my subtotal on my bill?
I really do appreciate all the help, it has helped me understand this stuff a lot better. Thanks
Greg
This is the situation. I have a frame box which consists of 5 chkboxes. My question is how exactally would i go about adding each of the different chkbox values when they are checked
For instance:
(Bagel toppings)
Cream Cheese (.$50)
Butter ($.25)
Blueberry jam ($.75)
Raspberry jam ($.75)
Peach jelly ($.75)
If i click on any one or two or all of the following, how would i go about adding that value to my subtotal on my bill?
I really do appreciate all the help, it has helped me understand this stuff a lot better. Thanks
Greg
If you guys ever need any help, just im me on AIM, and I am willing to help any time, I may not check the post all the time so just im me. And to make sure I know what I am talking about, I have 7 Microsoft Certifications, including an MCSD .Net
Option Explicit
Dim bagel_total, toppings, subTotal, total_tax, total_bill As Double
Const tax = 0.06
Const x = 25
Private Sub cmdCalc_Click()
'Bagel and Coffee Selection
If (optWhite = True) Then
If (optNone = True) Then
bagel_total = 1.25
End If
End If
If (optWhite = True) Then
If (optRegular = True) Then
bagel_total = 2.5
End If
End If
If (optWhite = True) Then
If (optCapp = True) Then
bagel_total = 3.25
End If
End If
If (optWhite = True) Then
If (optCafe = True) Then
bagel_total = 3
End If
End If
If (optWheat = True) Then
If (optNone = True) Then
bagel_total = 1.5
End If
End If
If (optWheat = True) Then
If (optRegular = True) Then
bagel_total = 2.75
End If
End If
If (optWheat = True) Then
If (optCapp = True) Then
bagel_total = 3.5
End If
End If
If (optWheat = True) Then
If (optCafe = True) Then
bagel_total = 3.75
End If
End If
'Toppings
If (chkCheese = vbChecked) Then
toppings = toppings + 0.5
End If
If (chkButter = vbChecked) Then
toppings = toppings + 0.25
End If
If (chkBlue = vbChecked) Then
toppings = toppings + 0.75
End If
If (chkRasp = vbChecked) Then
toppings = toppings + 0.75
End If
If (chkPeach = vbChecked) Then
toppings = toppings + 0.75
End If
subTotal = bagel_total + toppings
total_tax = subTotal * tax
total_bill = subTotal + total_tax
lblSubtotal.Caption = FormatCurrency(subTotal)
lblTax.Caption = FormatCurrency(total_tax)
lblTotal.Caption = FormatCurrency(total_bill)
picResult.Cls
picResult.FontBold = True
picResult.Print "Customer Reciept"
picResult.FontBold = False
picResult.Print
picResult.Print "Subtotal: "; Tab(x); FormatCurrency(subTotal)
picResult.Print "Tax: "; Tab(x); FormatCurrency(total_tax)
picResult.Print "Total: "; Tab(x); FormatCurrency(total_bill)
End Sub
Private Sub cmdExit_Click()
End
End Sub
Private Sub cmdPayment_Click()
Dim payment, cashDue As Single
payment = Val(InputBox("Enter the Pament", "Payment", FormatNumber(total_bill, 2)))
If (payment < total_bill) Then
MsgBox "Incorrect Amount!", vbOKOnly + vbCritical, "Error!"
Else
cashDue = payment - total_bill
picResult.Print "Payment"; Tab(x); FormatCurrency(payment)
picResult.Print "Change Due"; Tab(x); FormatCurrency(cashDue)
End If
End Sub
Dim bagel_total, toppings, subTotal, total_tax, total_bill As Double
Const tax = 0.06
Const x = 25
Private Sub cmdCalc_Click()
'Bagel and Coffee Selection
If (optWhite = True) Then
If (optNone = True) Then
bagel_total = 1.25
End If
End If
If (optWhite = True) Then
If (optRegular = True) Then
bagel_total = 2.5
End If
End If
If (optWhite = True) Then
If (optCapp = True) Then
bagel_total = 3.25
End If
End If
If (optWhite = True) Then
If (optCafe = True) Then
bagel_total = 3
End If
End If
If (optWheat = True) Then
If (optNone = True) Then
bagel_total = 1.5
End If
End If
If (optWheat = True) Then
If (optRegular = True) Then
bagel_total = 2.75
End If
End If
If (optWheat = True) Then
If (optCapp = True) Then
bagel_total = 3.5
End If
End If
If (optWheat = True) Then
If (optCafe = True) Then
bagel_total = 3.75
End If
End If
'Toppings
If (chkCheese = vbChecked) Then
toppings = toppings + 0.5
End If
If (chkButter = vbChecked) Then
toppings = toppings + 0.25
End If
If (chkBlue = vbChecked) Then
toppings = toppings + 0.75
End If
If (chkRasp = vbChecked) Then
toppings = toppings + 0.75
End If
If (chkPeach = vbChecked) Then
toppings = toppings + 0.75
End If
subTotal = bagel_total + toppings
total_tax = subTotal * tax
total_bill = subTotal + total_tax
lblSubtotal.Caption = FormatCurrency(subTotal)
lblTax.Caption = FormatCurrency(total_tax)
lblTotal.Caption = FormatCurrency(total_bill)
picResult.Cls
picResult.FontBold = True
picResult.Print "Customer Reciept"
picResult.FontBold = False
picResult.Print
picResult.Print "Subtotal: "; Tab(x); FormatCurrency(subTotal)
picResult.Print "Tax: "; Tab(x); FormatCurrency(total_tax)
picResult.Print "Total: "; Tab(x); FormatCurrency(total_bill)
End Sub
Private Sub cmdExit_Click()
End
End Sub
Private Sub cmdPayment_Click()
Dim payment, cashDue As Single
payment = Val(InputBox("Enter the Pament", "Payment", FormatNumber(total_bill, 2)))
If (payment < total_bill) Then
MsgBox "Incorrect Amount!", vbOKOnly + vbCritical, "Error!"
Else
cashDue = payment - total_bill
picResult.Print "Payment"; Tab(x); FormatCurrency(payment)
picResult.Print "Change Due"; Tab(x); FormatCurrency(cashDue)
End If
End Sub
Ok, this is the only thing that is stopping my program from running perfrect:
'Toppings
If (chkCheese = vbChecked) Then
toppings = toppings + 0.5
End If
If (chkButter = vbChecked) Then
toppings = toppings + 0.25
End If
If (chkBlue = vbChecked) Then
toppings = toppings + 0.75
End If
If (chkRasp = vbChecked) Then
toppings = toppings + 0.75
End If
If (chkPeach = vbChecked) Then
toppings = toppings + 0.75
End If
subTotal = bagel_total + toppings
total_tax = subTotal * tax
total_bill = subTotal + total_tax
everytime the calc button is hit with any of the chk boxes checked, it will add the total of what the chk boxes are to the subTotal/total_tax/total_bill every single time you hit the Calc button. Any idea of how to stop this from happening?
Thanks for the help.
Greg
'Toppings
If (chkCheese = vbChecked) Then
toppings = toppings + 0.5
End If
If (chkButter = vbChecked) Then
toppings = toppings + 0.25
End If
If (chkBlue = vbChecked) Then
toppings = toppings + 0.75
End If
If (chkRasp = vbChecked) Then
toppings = toppings + 0.75
End If
If (chkPeach = vbChecked) Then
toppings = toppings + 0.75
End If
subTotal = bagel_total + toppings
total_tax = subTotal * tax
total_bill = subTotal + total_tax
everytime the calc button is hit with any of the chk boxes checked, it will add the total of what the chk boxes are to the subTotal/total_tax/total_bill every single time you hit the Calc button. Any idea of how to stop this from happening?
Thanks for the help.
Greg
Private Sub cmdCalc_Click()
Dim cost, down_payment, months, years, loan_amount, percent_down As Integer
cost = Val(txtCost.Text)
down_payment = Val(txtDP.Text)
months = Val(txtMonths.Text)
years = months / 12
loan_amount = cost - down_payment
percent_down = Val(txtDP.Text / loan_amount)
lblLoanAmt.Caption = Format(loan_amount, "currency")
If optNew Then
ir = 0.089
Else
ir = 0.095
End If
lblAnnual.Caption = Format(ir, "percent")
If cost > 25000 Then
MsgBox "Incorrect Vehicle Cost!" + vbCr + "Must be less than $25,000 vbCritical"
txtCost.Text = ""
txtCost.SetFocus
Exit Sub
End If
If down_payment < cost * 0.05 Then
MsgBox "Must provide 5% down!" + vbCr + "Before loan can be approaved"
txtDP.Text = ""
txtDP.SetFocus
Exit Sub
End If
If months < 6 Or months > 48 Then
MsgBox "Incorrect Months!" + vbCr + "Must be between 6 and 48 months"
txtMonths.Text = ""
txtMonths.SetFocus
Exit Sub
End If
For i = 0 To 11
lblPayment(i).Caption = ""
lblPrincipal(i).Caption = ""
lblIR(i).Caption = ""
Payment = Pmt(ir / 12 / 1, months, -loan_amount)
lblPayment(i).Caption = FormatCurrency(Payment)
Principle = PPmt(ir / 12, 1, months, -loan_amount)
lblPrincipal(i).Caption = FormatCurrency(Principle)
Interest = IPmt(ir / 12, 1, months, -loan_amount)
lblIR(i).Caption = FormatCurrency(Interest)
Next i
End Sub
Dim cost, down_payment, months, years, loan_amount, percent_down As Integer
cost = Val(txtCost.Text)
down_payment = Val(txtDP.Text)
months = Val(txtMonths.Text)
years = months / 12
loan_amount = cost - down_payment
percent_down = Val(txtDP.Text / loan_amount)
lblLoanAmt.Caption = Format(loan_amount, "currency")
If optNew Then
ir = 0.089
Else
ir = 0.095
End If
lblAnnual.Caption = Format(ir, "percent")
If cost > 25000 Then
MsgBox "Incorrect Vehicle Cost!" + vbCr + "Must be less than $25,000 vbCritical"
txtCost.Text = ""
txtCost.SetFocus
Exit Sub
End If
If down_payment < cost * 0.05 Then
MsgBox "Must provide 5% down!" + vbCr + "Before loan can be approaved"
txtDP.Text = ""
txtDP.SetFocus
Exit Sub
End If
If months < 6 Or months > 48 Then
MsgBox "Incorrect Months!" + vbCr + "Must be between 6 and 48 months"
txtMonths.Text = ""
txtMonths.SetFocus
Exit Sub
End If
For i = 0 To 11
lblPayment(i).Caption = ""
lblPrincipal(i).Caption = ""
lblIR(i).Caption = ""
Payment = Pmt(ir / 12 / 1, months, -loan_amount)
lblPayment(i).Caption = FormatCurrency(Payment)
Principle = PPmt(ir / 12, 1, months, -loan_amount)
lblPrincipal(i).Caption = FormatCurrency(Principle)
Interest = IPmt(ir / 12, 1, months, -loan_amount)
lblIR(i).Caption = FormatCurrency(Interest)
Next i
End Sub


