|
AaronEvil
The GuitarVillain



Registered: 09/27/04
Posts: 1,706
Loc: California
Last seen: 13 years, 14 days
|
Visual Basic Help
#8071687 - 02/26/08 09:12 AM (16 years, 2 months ago) |
|
|
Hey Guys,
I am in a visual basic class with a terrible instructor and I am supposed to have a program done by tomorrow but I am sort of lost. Ill type the program outline below
An internet service provider offers three subscription packages to its customer, plus a discount for non profit organizations:
Package A: 10 hours for $9.95 per month. Addtional hours are $2 per hour.
Package B: 20 hours for $14.95 per month. Additional hours $1 per hour
Package C: Unlimited Service for $19.95 per month.
A non profit organization gets a 20% discount.
The user should select the package the customer has purchased (from a set of radio buttons) and enter the number of hours used. A check box captioned "Nonprofit Organization" should also appear on the form as well as a checkbox that says "Display potential savings". The application should calculate the total amount due and the the savings (if the savings box is checked). If the "Nonprofit Organization box is checked, 20% should be deducted from the total price.
So far I have the form completed and the math calculations written out on a sheet of paper. Im really just having problems bringing all the calculations into VB to be calculated and displayed.
Thanks for any help.
--------------------
There is not a lot of difference between a fox hole and a grave; but knowing that you dug your ditch and climbed in anyway.
|
Seuss
Error: divide byzero



Registered: 04/27/01
Posts: 23,480
Loc: Caribbean
Last seen: 3 months, 8 days
|
Re: Visual Basic Help [Re: AaronEvil]
#8072167 - 02/26/08 11:33 AM (16 years, 2 months ago) |
|
|
I know nothing about visual basic, thankfully, but can help a bit...
In general, start out small and try to get a program that does only one thing. Once you have that one thing working correctly, then add to it. Go slow and test to make sure it is working as you go. Don't try to write the entire thing in one go. Doing so makes it very difficult to isolate what is wrong when it doesn't work.
It sounds like a pretty basic usage of VB. I would google for visual basic tutorial or visual basic example or learning visual basic and you will probably find tons of easy to understand help. (You might need to add a -book to your search.)
Finally, I have seen a lot of e-books for visual basic on the various torrent sites. If nothing works else, these may help.
-------------------- Just another spore in the wind.
|
AaronEvil
The GuitarVillain



Registered: 09/27/04
Posts: 1,706
Loc: California
Last seen: 13 years, 14 days
|
Re: Visual Basic Help [Re: Seuss]
#8072182 - 02/26/08 11:36 AM (16 years, 2 months ago) |
|
|
I have been googling all moring and have found some help but the tough part is getting everything to display properly. At first I was trying to use Select Case but that didnt work to well so I now have a a lot of If Then and nested If Then statements which seem to get my calculations working for the most part. I think I may start over and do it step by step like you suggested testing each step along the way.
--------------------
There is not a lot of difference between a fox hole and a grave; but knowing that you dug your ditch and climbed in anyway.
|
tak
geo's henchman




Registered: 11/20/00
Posts: 3,776
Loc: nowhereland
|
Re: Visual Basic Help [Re: AaronEvil]
#8072254 - 02/26/08 11:55 AM (16 years, 2 months ago) |
|
|
I dont really know VB aside from what I have seen some places, so this is just an example of what could be done I guess.
Your teacher would probably shoot you for so many nested IF statements, and poor error checking...and I dont know how strings work so it probably wont compile.
Code:
ISP_Price=0 ISP_Savings=0
If RadioButton1.Checked = True Then
ISP_Price = ISP_Price + 9.95 If Textbox1.Value > 10 Then ISP_Price = ISP_Price + ((Textbox1.Value-10)*2) Endif
If Textbox1.value > 12 Then ISP_Savings = "You Would Save" ISP_Price - (14.95 + (Textbox1.Value-20)*1) " Switching to our 20 Hour Plan" If Textbox1.value > 16 Then ISP_Savings = "You Would Save" ISP_Price - 19.95 " Switching to Unlimited"
ElseIf RadioButton2.Checked = True Then
ISP_Price = ISP_Price + 14.95 If Textbox1.Value > 20 Then ISP_Price = ISP_Price + ((Textbox1.Value-20)*1) Endif
ElseIf RadioButton3.Checked = True Then
ISP_Price = ISP_Price + 19.95
End If
If Checkbox1.Checked = True Then ISP_Price = ISP_Price * 0.80 Endif
Label1.Value = ISP_Price
If Checkbox2.Checked = True Then Label2.Value=ISP_Savings
for the calculated savings, you would have to do some checking to make sure hours were over the standard grace time, so you dont drop into negative with your math, and repeat throughout. I am sure theres a much more efficient way but im not smart or a programmer
good luck!!
-------------------- The DJ's took pills to stay awake and play for seven days.
|
tak
geo's henchman




Registered: 11/20/00
Posts: 3,776
Loc: nowhereland
|
Re: Visual Basic Help [Re: tak]
#8072261 - 02/26/08 11:58 AM (16 years, 2 months ago) |
|
|
and id either put that type of code in a button they click to calculate, or create a function that contains that code, and any of your radio buttons, or checkboxes, or textboxes put a reference to that function with a value change -- not sure what its called in VB
-------------------- The DJ's took pills to stay awake and play for seven days.
|
Jrsxt
Stranger


Registered: 05/14/07
Posts: 1,043
|
Re: Visual Basic Help [Re: tak]
#8072282 - 02/26/08 12:10 PM (16 years, 2 months ago) |
|
|
Yeah. That looks about right. I've messed around with visual basic for year or so. If you have AIM or some kind of messenger I can help you.
|
AaronEvil
The GuitarVillain



Registered: 09/27/04
Posts: 1,706
Loc: California
Last seen: 13 years, 14 days
|
Re: Visual Basic Help [Re: tak]
#8072902 - 02/26/08 02:48 PM (16 years, 2 months ago) |
|
|
That helped me a lot to understand how to convert my calculations into a clickable button. I am using a Calculate control button for the calculations. Ill work on this and post more if I need additional help.
Thanks guys.
--------------------
There is not a lot of difference between a fox hole and a grave; but knowing that you dug your ditch and climbed in anyway.
|
encryptor


Registered: 05/15/03
Posts: 1,162
Last seen: 20 days, 9 hours
|
Re: Visual Basic Help [Re: AaronEvil]
#8091454 - 03/01/08 08:14 PM (16 years, 2 months ago) |
|
|
The solution above will work well with the language C. However the language C++ has more power and better methods, such as picking package A,B, or C should be done with a switch statement. Then call a the proper function to perform an operation. What level of code are you at? You should have stated what ideas your teacher is going over for this lab. Either way, I'm curious as to where your stuck, but if you want to do well your going to need to study this stuff, ask specific question and print out your code to see the "big picture". Only work on 1 function at a time and get it working before you move on to the next. Solve your problems on paper if you need to. A program that ultimately doesn't work is graded 0. Good luck!
|
AaronEvil
The GuitarVillain



Registered: 09/27/04
Posts: 1,706
Loc: California
Last seen: 13 years, 14 days
|
Re: Visual Basic Help [Re: encryptor]
#8092707 - 03/02/08 04:56 AM (16 years, 2 months ago) |
|
|
This wasnt a lab, it was my final. I ended up using the above code as a reference tool. I actually went with a "Select, Case" method. It made the code a lot smaller and easier to read. I also found that my flow chart was too confusing for me so I re-drew it on a different sheet of paper and ended up getting a copy of Visio from my school to clear it up. As far as I know the program worked flawlessly when I submitted it for grading. I wont know the actual grade until next friday (at the latest).
--------------------
There is not a lot of difference between a fox hole and a grave; but knowing that you dug your ditch and climbed in anyway.
|
|