-
November 18th, 2013, 10:12 AM
#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 10:38 AM.
Reason: added code tags
-
November 18th, 2013, 10:37 AM
#2
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.
-
November 18th, 2013, 10:38 PM
#3
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.
-
November 23rd, 2013, 05:52 AM
#4
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|