I have to create a shopping cart using 3 forms. There is a menu on the main form. If you select from the menu the PrintBook form, it gives you a list of books. If you select from the list, the name should populate the list box on the main form and then add the price of the book to the subtotal label on the main form also. When I try this it adds the book to the main form list box but places 0.00 in the Subtotal label instead of the price of the book.. See the code below. The first is for the main form and the 2nd is the print book form..
//This is the main forms code..
Option Strict On
Public Class frmMain
'Dim strInput As String ' Input
Dim strOut As String = String.Empty
Public selectChoice As Boolean = False
'Reset the Form Main
Private Sub mnuFileReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileReset.Click
lblSubtotal.Text = String.Empty
lblTax.Text = String.Empty
lblShipping.Text = String.Empty
lblTotal.Text = String.Empty
lstProducts.SelectedIndex = -1
End Sub
'End the Application
Private Sub mnuFileExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileExit.Click
Me.Close()
End Sub
'Display Print Book Form
Private Sub mnuProductsPrintBooks_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuProductsPrintBooks.Click
Dim printBooksForm As New frmPrintBooks()
'Display the print books form
printBooksForm.ShowDialog()
Dim strTemp As String = printBooksForm.getSelection()
If strTemp <> String.Empty Then
lstProducts.Items.Add(strTemp)
End If
UpdateCharges()
End Sub
Private Sub mnuProductsAudioBooks_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuProductsAudioBooks.Click
Dim audioBooksForm As New frmAudioBooks()
'Display the audio books form
audioBooksForm.ShowDialog()
Dim strTemp As String = audioBooksForm.getSelection2()
If strTemp <> String.Empty Then
lstProducts.Items.Add(strTemp)
End If
UpdateCharges()
End Sub
'Display an About Box
Private Sub mnuHelpAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuHelpAbout.Click
MessageBox.Show("You must be 18 or older to order & agree with our policies.")
End Sub
Private Sub UpdateCharges()
Dim Price As Decimal
Dim subTotal As Decimal = 0
Dim i As Integer
'Add selected book cost to subtotal
For i = 0 To (lstProducts.Items.Count - 1)
'lstProducts.Items(i.ToString())
Dim book As String = lstProducts.Items(i).ToString()
If book = "Feel the Stress(Print)" Then
Price = 12D
subTotal = subTotal + Price
ElseIf book = "The History of Scotland(Print)" Then
Price = 15D
subTotal = subTotal + Price
' 'lblSubtotal.Text = (subTotal.ToString("n2"))
End If
lblSubtotal.Text = (subTotal.ToString("n2"))
Next i
'Private Sub btnTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
' MessageBox.Show(strMessage)
'End Sub
[code][/code] Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
End Sub
End Class
//This is the print book form code
Private Sub cmdAddPrintBook_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddPrintBook.Click
'Dim strMessage As String
'add selection to main form
If lstPrintBooks.SelectedIndex > -1 Then
selection = lstPrintBooks.SelectedItem.ToString()
End If


