Need help with calculation

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2005
Posts: 30
Reputation: augie0216 is an unknown quantity at this point 
Solved Threads: 0
augie0216's Avatar
augie0216 augie0216 is offline Offline
Light Poster

Need help with calculation

 
0
  #1
May 16th, 2005
I'm trying to learn asp.net in vb.net. I have a form to order hats online because I'm learning only one hat at a time may be ordered. I have two listboxes one displays the size and the other the color, I have a checkbox which if checked adds a logo, a button which the user clicks to submit an order, and a label which confirms the order By displaying the message " The cost of your hat is (the total). Here is the rate scale:

White Blue White & Blue
Small $5.99 $6.99 $7.99
Medium $6.99 $7.99 $8.99
Large $7.99 $8.99 $9.99

Hats with a logo cost 3.00 regarless of size or color.

If someone could point me in the right direction I put this in the VB.net forum because (if I understand correctly) this calculation can be done vb.net, even though it's a web form. I'm not to good at expressing calculations. So this may take more than one post.

Thanks
Augie0216

"Help you give now may be help you get in the future"
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 793
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Solved Threads: 27
Team Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Need help with calculation

 
0
  #2
May 16th, 2005
Well you could do this many ways, but since you have not indicated that you are using a Database to store you information lets assume you don't and use an array.

You could use several one-dimensional arrays or one multidimensional array. Store the information, then based on the choise by the user it grabs that value from the array(s) and uses it in calculation.

Example: (pseudo-code)
....
Dim arSMALLCosts(3) as Float
Dim arMEDCosts(3) as Float
Dim arLARGECosts(3) as Float
Dim Cost as Float
Dim LogoFee as Float
Dim qty as Integer
Dim Total as Float

.... ' Fill your arrays with costs

....
' Use some sort of logic to determine if small, medium or large is selected

Dim nValue as Integer
nValue = ' Color of the size selected
....
Cost = arSMALLCosts(nValue) ' Assuming Size selected was small

if chkLogo = True Then
LogoFee = 3.00
else
LogoFee = 0
end if

Total = qty * Cost

lblTotal.Text = Total


...

Hope this helps



Originally Posted by augie0216
I'm trying to learn asp.net in vb.net. I have a form to order hats online because I'm learning only one hat at a time may be ordered. I have two listboxes one displays the size and the other the color, I have a checkbox which if checked adds a logo, a button which the user clicks to submit an order, and a label which confirms the order By displaying the message " The cost of your hat is (the total). Here is the rate scale:

White Blue White & Blue
Small $5.99 $6.99 $7.99
Medium $6.99 $7.99 $8.99
Large $7.99 $8.99 $9.99

Hats with a logo cost 3.00 regarless of size or color.

If someone could point me in the right direction I put this in the VB.net forum because (if I understand correctly) this calculation can be done vb.net, even though it's a web form. I'm not to good at expressing calculations. So this may take more than one post.

Thanks
Augie0216

"Help you give now may be help you get in the future"
Assistant Manager, Pharmacy Informatics
Wordpress Learning Blog
Updated : ASP.Net Login Code
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 30
Reputation: augie0216 is an unknown quantity at this point 
Solved Threads: 0
augie0216's Avatar
augie0216 augie0216 is offline Offline
Light Poster

Re: Need help with calculation

 
0
  #3
May 16th, 2005
In your calculation could you please explain how the code knows which item was selected in the listboxes. Plus I don't have any idea what float means.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 55
Reputation: NPH is an unknown quantity at this point 
Solved Threads: 1
NPH NPH is offline Offline
Junior Poster in Training

Re: Need help with calculation

 
0
  #4
May 17th, 2005
Suppose the size listbox has Small, Medium, and Large
Suppose the color listbox has White, Blue, White & Blue

Then write:

dim total as Double

//check if its small and white
If lstBoxSize.SelectedIndex = 0 And lstBoxColor.SelectedIndex = 0 then
total = total + 5.99
End if
//check if its small and blue
If lstBoxSize.SelectedIndex = 0 And lstBoxColor.SelectedIndex = 1 then
total = total + 6.99
End if
//check if its small and white&blue
If lstBoxSize.SelectedIndex = 0 And lstBoxColor.SelectedIndex = 2 then
total = total + 7.99
End if
//check if its medium and white
If lstBoxSize.SelectedIndex = 1 And lstBoxColor.SelectedIndex = 0 then
total = total + 6.99
End if
//and so on...

//check if logo is selected and set total to 3 if it is selected

For more programming help, visit www.NeedProgrammingHelp.com or email me at NeedProgrammingHelp@hotmail.com

Alex.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC