Groups | Blog | Home
all groups > visual studio .net enterprise tools > april 2004 >

visual studio .net enterprise tools : Help with store page


Daniel L. McGrew
4/1/2004 10:14:56 AM
Hello,
I'm looking for ways to write code for a product page... There are five
objects on the page, priced $65, $55, $45, $35, & $25.... there is an "add
to cart" button under each item...
The code needs to total the items in a textbox labeled
txtQuantity.Text
The products also need to be totaled on this page in a label
named lblOrder

So far, I have this:
Private Sub btn512_ServerClick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn512.ServerClick

Dim Cost As Integer

Cost = Convert.ToInt32(txtQuantity.Text)

Cost = Cost + 1

txtQuantity.Text = Cost

End Sub


--
Love is very patient and kind, never jealous or envious, never boastful or
proud, never haughty or selfish or rude. Love does not demand its own way.
It is not irritable or touchy. It does not hold grudges and will hardly even
notice when other do it wrong. It is never glad about injustice, but
rejoiced whenever truth wins out. If you love someone you will be loyal to
him no matter what the cost. You will always believe in him, always expect
the best of him, and always stand your ground in defending him. All the
special gifts and powers from God will someday come to an end, but love goes
on forever. There are three things that remain-----faith, hope, and
love-----and the greatest of these is LOVE. 1 Corinthians 13:4 - 8, 13 The
greatest ........ is LOVE.

http://www.northforkhoney.com (Greatest Honey on Earth)
http://www.bible.com (Greatest Book on Earth !!!)


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.648 / Virus Database: 415 - Release Date: 3/31/2004

Daniel L. McGrew
4/3/2004 4:03:30 PM
I was using a DIM statement in the beginning of each sub... so, it was
resetting it to a blank and you can't convert a blank...
Here is what it should look like..:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here.

'Sets hidden cost label to "0" to initialize the text property

If (IsPostBack = False) Then

lblCostHidden.Text = 0

End If

'Sets Order label to "$0.00" to initialize the text property

If (IsPostBack = False) Then

lblOrder.Text = "$0.00"

End If

'Sets Quantity text box to "0" to initialize teh text property

If (IsPostBack = False) Then

txtQuantity.Text = 0

End If

End Sub

'Put all "add to cart" button code in it's own region for neatness, leave
expanded for instructor

#Region " 'add to cart' buttons "

Private Sub btn512_ServerClick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn512.ServerClick

'Convert string in Quantity text box to a long integer and set it equal to
the variable "Cost"

cost = Convert.ToInt32(txtQuantity.Text)

'add one to the integer in the quantity box each time it is selected and
convert it back to a string

txtQuantity.Text = (cost + 1).ToString

'Hidden cost field holds and adds the quatity for this button plus all
selected items

lblCostHidden.Text = Convert.ToDouble(lblCostHidden.Text) +
Convert.ToDouble(lbl512.Text)

'Converts CostHidden label to double and the back to string as currency for
the label

lblOrder.Text = Convert.ToDouble(lblCostHidden.Text).ToString("C")

End Sub

Private Sub btn529_ServerClick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn529.ServerClick

'Convert string in Quantity text box to a long integer and set it equal to
the variable "Cost"

cost = Convert.ToInt32(txtQuantity.Text)

'add one to the integer in the quantity box each time it is selected and
convert it back to a string

txtQuantity.Text = (cost + 1).ToString

'Hidden cost field holds and adds the quatity for this button plus all
selected items

lblCostHidden.Text = Convert.ToDouble(lblCostHidden.Text) +
Convert.ToDouble(lbl529.Text)

'Converts CostHidden label to double and the back to string as currency for
the label

lblOrder.Text = Convert.ToDouble(lblCostHidden.Text).ToString("C")

End Sub

Private Sub btn547_ServerClick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn547.ServerClick

'Convert string in Quantity text box to a long integer and set it equal to
the variable "Cost"

cost = Convert.ToInt32(txtQuantity.Text)

'add one to the integer in the quantity box each time it is selected and
convert it back to a string

txtQuantity.Text = (cost + 1).ToString

'Hidden cost field holds and adds the quatity for this button plus all
selected items

lblCostHidden.Text = Convert.ToDouble(lblCostHidden.Text) +
Convert.ToDouble(lbl547.Text)

'Converts CostHidden label to double and the back to string as currency for
the label

lblOrder.Text = Convert.ToDouble(lblCostHidden.Text).ToString("C")

End Sub

Private Sub btn528_ServerClick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn528.ServerClick

'Convert string in Quantity text box to a long integer and set it equal to
the variable "Cost"

cost = Convert.ToInt32(txtQuantity.Text)

'add one to the integer in the quantity box each time it is selected and
convert it back to a string

txtQuantity.Text = (cost + 1).ToString

'Hidden cost field holds and adds the quatity for this button plus all
selected items

lblCostHidden.Text = Convert.ToDouble(lblCostHidden.Text) +
Convert.ToDouble(lbl528.Text)

'Converts CostHidden label to double and the back to string as currency for
the label

lblOrder.Text = Convert.ToDouble(lblCostHidden.Text).ToString("C")

End Sub

Private Sub btn535_ServerClick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn535.ServerClick

'Convert string in Quantity text box to a long integer and set it equal to
the variable "Cost"

cost = Convert.ToInt32(txtQuantity.Text)

'add one to the integer in the quantity box each time it is selected and
convert it back to a string

txtQuantity.Text = (cost + 1).ToString

'Hidden cost field holds and adds the quatity for this button plus all
selected items

lblCostHidden.Text = Convert.ToDouble(lblCostHidden.Text) +
Convert.ToDouble(lbl535.Text)

'Converts CostHidden label to double and the back to string as currency for
the label

lblOrder.Text = Convert.ToDouble(lblCostHidden.Text).ToString("C")

End Sub

#End Region


--
Love is very patient and kind, never jealous or envious, never boastful or
proud, never haughty or selfish or rude. Love does not demand its own way.
It is not irritable or touchy. It does not hold grudges and will hardly even
notice when other do it wrong. It is never glad about injustice, but
rejoiced whenever truth wins out. If you love someone you will be loyal to
him no matter what the cost. You will always believe in him, always expect
the best of him, and always stand your ground in defending him. All the
special gifts and powers from God will someday come to an end, but love goes
on forever. There are three things that remain-----faith, hope, and
love-----and the greatest of these is LOVE. 1 Corinthians 13:4 - 8, 13 The
greatest ........ is LOVE.

http://www.northforkhoney.com (Greatest Honey on Earth)
http://www.bible.com (Greatest Book on Earth !!!)
[quoted text, click to view]
AddThis Social Bookmark Button