1 Replies - 259 Views - Last Post: 02 November 2017 - 08:22 PM Rate Topic: -----

#1 killahrepublic  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 02-April 16

In need of assistance with basic shopping cart program

Posted 02 November 2017 - 06:56 PM

So I am working on a somewhat basic "shopping cart" Program. I actually saw similar programs that people had issues with, however none of my answers were solved and I have been beating myself up over this for a few hours now. I have a good portion of it done, however i am running into some issues that are preventing me from continuing. Right now, when i add books to the cart, they appear correctly, however the subtotal does not add, it just shows the value of the last book i added. I also cannot understand how to remove the value of a book from the subtotal. The book will remove from the list itself but will nut subtract from the subtotal. I have a Sub for Shipping, and i want to make another one for Tax. Here is my code for all of the forms. If someone could tell me if im going in the right direction or any tips that would be great!



Public Class Form1

    Dim frmAudio As New AudioBooks 'makes the audio form instance
    Dim frmPrint As New PrintBooks 'makes the print form instance


    Private Sub mnuProductsPrintBooks_Click(sender As Object, e As EventArgs) Handles mnuProductsPrintBooks.Click
        frmPrint.ShowDialog() 'opens Print Books Form
    End Sub

    Private Sub btnRemove_Click(sender As Object, e As EventArgs) Handles btnRemove.Click
        If lstMain.SelectedIndex <> -1 Then
            lstMain.Items.RemoveAt(lstMain.SelectedIndex)
        End If
    End Sub

    Private Sub mnuProductsAudioBooks_Click(sender As Object, e As EventArgs) Handles mnuProductsAudioBooks.Click
        frmAudio.ShowDialog() 'opens Audio Books Form
    End Sub

    Private Sub mnuFileReset_Click(sender As Object, e As EventArgs) Handles mnuFileReset.Click
        lstMain.Items.Clear() 'Clears main list
        lblShipping.Text = String.Empty
        lblSubTotal.Text = String.Empty
        lblTax.Text = String.Empty
        lblTotal.Text = String.Empty
    End Sub

    Private Sub mnuFileExit_Click(sender As Object, e As EventArgs) Handles mnuFileExit.Click
        Me.Close() 'exit
    End Sub

    Public Sub Ship(ByRef decShipping As Decimal)
        decShipping = lstMain.Items.Count * 2.0
        lblShipping.Text = decShipping
    End Sub

    Private Sub mnuHelpAbout_Click(sender As Object, e As EventArgs) Handles mnuHelpAbout.Click
        MessageBox.Show("This program was written for CIT 161!")
    End Sub
End Class
 

Module Module1
    'this module will contain everything that will be used by multiple forms
    'all global variables
    Public decSubTotal As Decimal
    Public decTaxTotal As Decimal
    Public decShippingCosts As Decimal
    Const decShip As Decimal = 2.0
    Const decTax As Decimal = 0.06

    Public Sub BookPrice(ByRef strTitle As String, ByRef intCost As Decimal)

        Select Case strTitle
            Case "I Did It Your Way (Print)"
                intCost = 11.95
            Case "The History of Scotland (Print)"
                intCost = 14.5
            Case "Learn Calculus in One Day (Print)"
                intCost = 29.95
            Case "Feel the Stress (Print)"
                intCost = 18.5
            Case "Learn Calculus in One Day (Audio)"
                intCost = 29.95
            Case "The History of Scotland (Audio)"
                intCost = 14.5
            Case "The Science of Body Language (Audio)"
                intCost = 12.95
            Case "Relaxation Techniques (Audio)"
                intCost = 11.5
        End Select
    End Sub





End Module 

 Public Class PrintBooks

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub

    Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
        Dim strSelection As String

        Dim decBookCost As Decimal
        strSelection = lstPrint.SelectedItem.ToString
        BookPrice(strSelection, decBookCost)
        Form1.lstMain.Items.Add(strSelection & "  " & " $ " & decBookCost)
        Form1.lblSubTotal.Text = FormatCurrency(Val(Form1.lblSubTotal.Text) + decBookCost)

    End Sub
End Class 


Is This A Good Question/Topic? 0
  • +

Replies To: In need of assistance with basic shopping cart program

#2 killahrepublic  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 02-April 16

Re: In need of assistance with basic shopping cart program

Posted 02 November 2017 - 08:22 PM

I actually with some help of others, made some additions to my select case and resolved my problems.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1