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

3
Contributors
3
Replies
4
Views
12 Years
Discussion Span
Last Post by NPH

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

:cool:

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

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.

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.