944,120 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 4290
  • VB.NET RSS
May 16th, 2005
0

Need help with calculation

Expand Post »
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"
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
augie0216 is offline Offline
30 posts
since Mar 2005
May 16th, 2005
0

Re: Need help with calculation

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



Quote 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"
Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003
May 16th, 2005
0

Re: Need help with calculation

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.
Reputation Points: 10
Solved Threads: 0
Light Poster
augie0216 is offline Offline
30 posts
since Mar 2005
May 17th, 2005
0

Re: Need help with calculation

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.
NPH
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
NPH is offline Offline
55 posts
since May 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: pass OleDbDataReader to table
Next Thread in VB.NET Forum Timeline: connecting to access via vb.net-HELP!!!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC