CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Nov 2013

    beginner needs help code not working

    Hi everyone I am trying to create an invoice where the form as input and output labels, But when i run it i get no errors but the lables don't output, its obviously the code can anyone help

     Private Sub cmdAmountDue_Click(sender As Object, e As EventArgs) Handles cmdAmountDue.Click
            '1.Declare Variables
            Dim strCustomerName As String
            Dim strElectricalItem As String
            Dim decUsualPrice As Decimal
            Dim intUnitsBought As Integer
            Dim intDeliveryDistance As Integer
            Dim decTotalPrice As Decimal
            Dim decReductionAvailable As Decimal
            Dim decPriceAfterReduction As Decimal
            Dim decDeliveryCharge As Decimal
            Dim decAmountDue As Decimal
            Dim decVatAmount As Decimal
            Const decVAT As Decimal = 0.21
            '2. Input Values
            strCustomerName = txtCustomerName.Text
            strElectricalItem = txtElectricalItem.Text
            decUsualPrice = txtUsualPrice.Text
            intUnitsBought = txtUnitsBought.Text
            intDeliveryDistance = txtDeliveryDistance.Text
            '3. Calculate Total Price
            decTotalPrice = intUnitsBought * decUsualPrice
            '4. calculate reduction Available
            decReductionAvailable = Val(lblReductionAvailable.Text)
            Select Case decUsualPrice
                Case 0 To 200
                    decReductionAvailable = decUsualPrice * 0.2
                Case 201 To 400
                    decReductionAvailable = decUsualPrice * 0.25
                Case Is > 400
                    decReductionAvailable = decUsualPrice * 0.3
            End Select
            ' 5 Calculate Price after Reduction
            decPriceAfterReduction = decTotalPrice - decReductionAvailable
            decVatAmount = decPriceAfterReduction * decVAT
            decAmountDue = decPriceAfterReduction + decVatAmount
            If intDeliveryDistance <= 20 Then
                decDeliveryCharge = 2.0
            ElseIf intDeliveryDistance > 20 Then
                decDeliveryCharge = 2.5
            End If
            decTotalPrice = FormatCurrency(lblTotalPrice, 2)
            decReductionAvailable = FormatCurrency(lblReductionAvailable, 2)
            decPriceAfterReduction = FormatCurrency(lblPriceAfterReduction, 2)
            decVatAmount = FormatCurrency(lblVAT, 2)
            decDeliveryCharge = FormatCurrency(lblDeliveryCharge, 2)
            decAmountDue = FormatCurrency(lblAmountDue, 2)
    Last edited by HanneSThEGreaT; November 18th, 2013 at 09:38 AM. Reason: added code tags

  2. #2
    Join Date
    Jul 2001
    Sunny South Africa

    Re: beginner needs help code not working

    Welcome to the forums!

    Please take time to read this thread :


    It explains the use of Code tags on this forum.

  3. #3
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008

    Re: beginner needs help code not working

    Well I see 2 things right off
    1: You are not getting the value you might think here
    decTotalPrice = FormatCurrency(lblTotalPrice, 2)
    Should be
    decTotalPrice = FormatCurrency(lblTotalPrice.Text, 2)
    This issue occurs on several lines

    2: You are never assigning anything to display
    At some point if you expect to see something appear in a label then you must tell it to do so

    Always use [code][/code] tags when posting code.

  4. #4
    Join Date
    Dec 2002
    Birmingham UK

    Re: beginner needs help code not working

    To display context in your label the code should be

    label.text = 13345 or "string"

    decTotalPrice = FormatCurrency(lblTotalPrice.Text, 2)

    the above is just going to store the value of lbltotalprice.text to variable decTotalPrice

    hope above helps
    Waheed Rafiq


    MCP x 2 , Network+.CNNA

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.