beginner needs help code not working
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: beginner needs help code not working

  1. #1
    Join Date
    Nov 2013
    Posts
    1

    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

    Code:
     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
    Location
    Sunny South Africa
    Posts
    11,092

    Re: beginner needs help code not working

    Welcome to the forums!

    Please take time to read this thread :

    http://forums.codeguru.com/showthrea...for-more-info)

    It explains the use of Code tags on this forum.

  3. #3
    DataMiser is online now Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,844

    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
    Code:
    decTotalPrice = FormatCurrency(lblTotalPrice, 2)
    Should be
    Code:
    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

    Code:
    MyLabel.Text=SomeValue
    Always use [code][/code] tags when posting code.

  4. #4
    Join Date
    Dec 2002
    Location
    Birmingham UK
    Posts
    83

    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

    www.waheedrafiq.com


    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

This is a CodeGuru survey question.


Featured


HTML5 Development Center