locked
what is my error stating in bold RRS feed

  • Question

  • Public Class Form1
        Const _cdecPricePerRivets As Decimal = 0.31D
        Const _cdecPricePerBolts As Decimal = 1.07D
        Const _cdecPricePerWashers As Decimal = 0.086D
        Const _cdecPricePerNuts As Decimal = 0.97D
        Const _cdecPricePerSprings As Decimal = 2.19D
        Const _cdecTaxRate As Decimal = 0.08625D
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        End Sub

        Private Sub btnCalculate Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
            Dim strNumberOfRivets As String
            Dim strNumberOfBolts As String
            Dim strNumberOfWashers As String
            Dim strNumberOfNuts As String
            Dim strNumberOfSprings As String
            Dim intNumberOfRivets As Integer
            Dim intNumberOfBolts As Integer
            Dim intNumberOfWashers As Integer
            Dim intNumberOfNuts As Integer
            Dim intNumberOfSprings As Integer
            Dim decCostOfRivets As Decimal
            Dim decCostOfBolts As Decimal
            Dim decCostOfWashers As Decimal
            Dim decCostofNuts As Decimal
            Dim decCostOfSprings As Decimal
            Dim decSubTotal As Decimal
            Dim decTaxAmount As Decimal
            Dim decTotal As Decimal


            strNumberOfRivets = txtNumberOfRivets.Text
            intNumberOfRivets = Convert.ToInt32(strNumberOfRivets)
            decCostOfRivets = intNumberOfRivets * _cdecPricePerRivets
            lblCostOfRivets.Text = decCostOfRivets.ToString("C")
            strNumberOfBolts = txtNumberOfBolts.Text
            intNumberOfBolts = Convert.ToInt32(strNumberOfBolts)
            decCostOfBolts = intNumberOfBolts * _cdecPricePerBolts
            lblCostOfBolts.Text = decCostOfBolts.ToString("C")
            strNumberOfWashers = txtNumberOfWashers.Text
            intNumberOfWashers = Convert.ToInt32(strNumberOfWashers)
            decCostOfWashers = intNumberOfWashers * _cdecPricePerWashers
            lblCostOfWashers.Text = decCostOfWashers.ToString("C")
            strNumberOfNuts = txtNumberOfNuts.Text
            intNumberOfNuts = Convert.ToInt32(strNumberOfNuts)
            decCostofNuts = intNumberOfWashers * _cdecPricePerNuts
            lblCostOfNuts.Text = decCostofNuts.ToString("C")
            strNumberOfSprings = txtNumberOfSprings.Text
            intNumberOfSprings = Convert.ToInt32(strNumberOfSprings)
            decCostOfSprings = intNumberOfSprings * _cdecPricePerSprings
            lblCostOfSprings.Text = decCostOfSprings.ToString("C")
            decSubTotal = decCostOfRivets + decCostOfBolts + decCostOfWashers + decCostofNuts + decCostOfSprings
            decTaxAmount = decSubTotal * _cdecTaxRate
            decTotal = decSubTotal + decTaxAmount

            lblSubTotal.Text = decSubTotal.ToString("C")
            lblTax.Text = decTaxAmount.ToString("C")
            lblTotalCostInShoppingCart.Text = decTotal.ToString("C")

            lblCostOfRivets.Visible = True
            lblCostOfBolts.Visible = True
            lblCostOfWashers.Visible = True
            lblCostOfNuts.Visible = True
            lblCostOfSprings.Visible = True
            lblSubTotal.Visible = True
            lblTax.Visible = True
            lblTotalCostInShoppingCart.Visible = True



        End Sub

        Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
            txtNumberOfRivets.Clear()
            txtNumberOfBolts.Clear()
            txtNumberOfWashers.Clear()
            txtNumberOfNuts.Clear()
            txtNumberOfSprings.Clear()
            lblCostOfRivets.Text = ""
            lblCostOfBolts.Text = ""
            lblCostOfWashers.Text = ""
            lblCostOfNuts.Text = ""
            lblCostOfSprings.Text = ""
            txtNumberOfRivets.Focus()
            txtNumberOfBolts.Focus()
            txtNumberOfWashers.Focus()
            txtNumberOfNuts.Focus()
            txtNumberOfSprings.Focus()





        End Sub

        Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
            Close()
        End Sub
    End Class
    Saturday, July 25, 2020 1:44 AM

All replies

  • I don't see an issue with this code

    If Integer.TryParse(txtNumberOfRivets.Text, intNumberOfRivets) Then
        decCostOfRivets = intNumberOfRivets * _cdecPricePerRivets
        lblCostOfRivets.Text = decCostOfRivets.ToString("C")
    End If


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Saturday, July 25, 2020 2:24 AM
  • Hi 13k,

    How is the question going? 

    Could you provide more information about your error? It will help us analyze your problem.

    We are waiting for your update.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, July 28, 2020 9:05 AM