EDN Admin
Well-known member
Im trying to create a program to calculate rental charges based on hours entered. I have the program and calculations all figured out, but when I run the program, the charges arent showing while the total hours and the number of times the calculate
button, or total rentals, does. I believe the problem lies in this part of the code. Does anybody have any ideas? Oh, and Im running Visual Basic 2010
<span style="font-size:small <span style="font-size:small
<p style="line-height:normal; margin-bottom:0pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt Declare the Variables
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Private
<span style="font-family:Times New Roman,serif; font-size:12pt TotalHoursInteger
<span style="color:blue As Integer
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Private
<span style="font-family:Times New Roman,serif; font-size:12pt RentalsCountInteger
<span style="color:blue As Integer
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Private
<span style="font-family:Times New Roman,serif; font-size:12pt TotalChargesDecimal
<span style="color:blue As Decimal
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Private
<span style="font-family:Times New Roman,serif; font-size:12pt AverageChargesDecimal
<span style="color:blue As Decimal
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Const
<span style="font-family:Times New Roman,serif; font-size:12pt RENTAL_RATE_DECIMAL
<span style="color:blue AsDecimal = 99.99D
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Const
<span style="font-family:Times New Roman,serif; font-size:12pt AAAMEMBERSDISCOUNT_RATE_DECIMAL
<span style="color:blue As Decimal = 149.99D
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Dim
<span style="font-family:Times New Roman,serif; font-size:12pt CurrentRentalChargeDecimal
<span style="color:blue As Decimal
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Dim
<span style="font-family:Times New Roman,serif; font-size:12pt HoursEnteredInteger
<span style="color:blue AsInteger
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Private Sub
<span style="font-family:Times New Roman,serif; font-size:12pt CalculateButton_Click(<span style="color:blue By Val
sender <span style="color:blue As System.Object, <span style="color:blue
By Val e <span style="color:blue As System.EventArgs) <span style="color:blue
Handles CalculateButton.Click
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:MS Gothic; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:MS Gothic; font-size:12pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt Declare the Discounts
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Const
<span style="font-family:Times New Roman,serif; font-size:12pt THREEHOURDISCOUNT_RATE_DECIMAL
<span style="color:blue As Decimal = 0.105D
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Const
<span style="font-family:Times New Roman,serif; font-size:12pt TENHOURDISCOUNT_RATE_DECIMAL
<span style="color:blue As Decimal = 0.15D
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Const
<span style="font-family:Times New Roman,serif; font-size:12pt TWENTYFOURHOURDISCOUNT_RATE_DECIMAL
<span style="color:blue As Decimal = 0.2D
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:MS Gothic; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt Convert hours text into numeric and assign a variable
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt HoursEnteredInteger =
<span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Integer<span style="font-family:Times New Roman,serif; font-size:12pt .Parse(HoursRentedTextBox.Text)
<p style="line-height:normal; margin-bottom:0pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt Adding to the total rentals and hours
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt RentalsCountInteger += 1
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt TotalHoursInteger += HoursEnteredInteger
<p style="line-height:normal; margin-bottom:0pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt Determine discount based on hours rented
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt If
<span style="font-family:Times New Roman,serif; font-size:12pt TotalHoursInteger < 3
<span style="color:blue Then
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt CurrentRentalChargeDecimal = RENTAL_RATE_DECIMAL * HoursEnteredInteger
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt If
<span style="font-family:Times New Roman,serif; font-size:12pt TotalHoursInteger > 3
<span style="color:blue Then CurrentRentalChargeDecimal = (RENTAL_RATE_DECIMAL * HoursEnteredInteger) - (RENTAL_RATE_DECIMAL * HoursEnteredInteger * THREEHOURDISCOUNT_RATE_DECIMAL)
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt If
<span style="font-family:Times New Roman,serif; font-size:12pt TotalHoursInteger > 10
<span style="color:blue Then CurrentRentalChargeDecimal = (RENTAL_RATE_DECIMAL * HoursEnteredInteger) - (RENTAL_RATE_DECIMAL * HoursEnteredInteger * TENHOURDISCOUNT_RATE_DECIMAL)
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt If
<span style="font-family:Times New Roman,serif; font-size:12pt TotalHoursInteger > 24
<span style="color:blue Then CurrentRentalChargeDecimal = (RENTAL_RATE_DECIMAL * HoursEnteredInteger) - (RENTAL_RATE_DECIMAL * HoursEnteredInteger * TWENTYFOURHOURDISCOUNT_RATE_DECIMAL)
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt EndIf
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt Add the current charge to the total charges And Display
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt TotalChargesDecimal += CurrentRentalChargeDecimal
<p style="line-height:normal; margin-bottom:0pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt Determine Averages for current and total charges.
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt AverageChargesDecimal = TotalChargesDecimal / HoursEnteredInteger
<p style="line-height:normal; margin-bottom:0pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt Format and Display Data
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt RentalChargesLabel.Text = CurrentRentalChargeDecimal.ToString(<span style="color:#a31515; font-family:Times New Roman,serif; font-size:12pt "c"<span style="font-family:Times New Roman,serif; font-size:12pt )
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt TotalHoursLabel.Text = TotalHoursInteger.ToString(<span style="color:#a31515; font-family:Times New Roman,serif; font-size:12pt "n"<span style="font-family:Times New Roman,serif; font-size:12pt )
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt TotalRentalsLabel.Text = RentalsCountInteger.ToString(<span style="color:#a31515; font-family:Times New Roman,serif; font-size:12pt "n"<span style="font-family:Times New Roman,serif; font-size:12pt )
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt AverageChargesLabel.Text = AverageChargesDecimal.ToString<span style="color:#a31515 "c")
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt TotalChargesLabel.Text = TotalChargesDecimal.ToString(<span style="color:#a31515; font-family:Times New Roman,serif; font-size:12pt "c"<span style="font-family:Times New Roman,serif; font-size:12pt )
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt EndSub
<br/>
View the full article
button, or total rentals, does. I believe the problem lies in this part of the code. Does anybody have any ideas? Oh, and Im running Visual Basic 2010
<span style="font-size:small <span style="font-size:small
<p style="line-height:normal; margin-bottom:0pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt Declare the Variables
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Private
<span style="font-family:Times New Roman,serif; font-size:12pt TotalHoursInteger
<span style="color:blue As Integer
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Private
<span style="font-family:Times New Roman,serif; font-size:12pt RentalsCountInteger
<span style="color:blue As Integer
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Private
<span style="font-family:Times New Roman,serif; font-size:12pt TotalChargesDecimal
<span style="color:blue As Decimal
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Private
<span style="font-family:Times New Roman,serif; font-size:12pt AverageChargesDecimal
<span style="color:blue As Decimal
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Const
<span style="font-family:Times New Roman,serif; font-size:12pt RENTAL_RATE_DECIMAL
<span style="color:blue AsDecimal = 99.99D
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Const
<span style="font-family:Times New Roman,serif; font-size:12pt AAAMEMBERSDISCOUNT_RATE_DECIMAL
<span style="color:blue As Decimal = 149.99D
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Dim
<span style="font-family:Times New Roman,serif; font-size:12pt CurrentRentalChargeDecimal
<span style="color:blue As Decimal
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Dim
<span style="font-family:Times New Roman,serif; font-size:12pt HoursEnteredInteger
<span style="color:blue AsInteger
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Private Sub
<span style="font-family:Times New Roman,serif; font-size:12pt CalculateButton_Click(<span style="color:blue By Val
sender <span style="color:blue As System.Object, <span style="color:blue
By Val e <span style="color:blue As System.EventArgs) <span style="color:blue
Handles CalculateButton.Click
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:MS Gothic; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:MS Gothic; font-size:12pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt Declare the Discounts
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Const
<span style="font-family:Times New Roman,serif; font-size:12pt THREEHOURDISCOUNT_RATE_DECIMAL
<span style="color:blue As Decimal = 0.105D
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Const
<span style="font-family:Times New Roman,serif; font-size:12pt TENHOURDISCOUNT_RATE_DECIMAL
<span style="color:blue As Decimal = 0.15D
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Const
<span style="font-family:Times New Roman,serif; font-size:12pt TWENTYFOURHOURDISCOUNT_RATE_DECIMAL
<span style="color:blue As Decimal = 0.2D
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:MS Gothic; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt Convert hours text into numeric and assign a variable
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt HoursEnteredInteger =
<span style="color:blue; font-family:Times New Roman,serif; font-size:12pt Integer<span style="font-family:Times New Roman,serif; font-size:12pt .Parse(HoursRentedTextBox.Text)
<p style="line-height:normal; margin-bottom:0pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt Adding to the total rentals and hours
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt RentalsCountInteger += 1
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt TotalHoursInteger += HoursEnteredInteger
<p style="line-height:normal; margin-bottom:0pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt Determine discount based on hours rented
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt If
<span style="font-family:Times New Roman,serif; font-size:12pt TotalHoursInteger < 3
<span style="color:blue Then
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt CurrentRentalChargeDecimal = RENTAL_RATE_DECIMAL * HoursEnteredInteger
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt If
<span style="font-family:Times New Roman,serif; font-size:12pt TotalHoursInteger > 3
<span style="color:blue Then CurrentRentalChargeDecimal = (RENTAL_RATE_DECIMAL * HoursEnteredInteger) - (RENTAL_RATE_DECIMAL * HoursEnteredInteger * THREEHOURDISCOUNT_RATE_DECIMAL)
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt If
<span style="font-family:Times New Roman,serif; font-size:12pt TotalHoursInteger > 10
<span style="color:blue Then CurrentRentalChargeDecimal = (RENTAL_RATE_DECIMAL * HoursEnteredInteger) - (RENTAL_RATE_DECIMAL * HoursEnteredInteger * TENHOURDISCOUNT_RATE_DECIMAL)
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt If
<span style="font-family:Times New Roman,serif; font-size:12pt TotalHoursInteger > 24
<span style="color:blue Then CurrentRentalChargeDecimal = (RENTAL_RATE_DECIMAL * HoursEnteredInteger) - (RENTAL_RATE_DECIMAL * HoursEnteredInteger * TWENTYFOURHOURDISCOUNT_RATE_DECIMAL)
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt EndIf
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt Add the current charge to the total charges And Display
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt TotalChargesDecimal += CurrentRentalChargeDecimal
<p style="line-height:normal; margin-bottom:0pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt Determine Averages for current and total charges.
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt AverageChargesDecimal = TotalChargesDecimal / HoursEnteredInteger
<p style="line-height:normal; margin-bottom:0pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:green; font-family:Times New Roman,serif; font-size:12pt Format and Display Data
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt RentalChargesLabel.Text = CurrentRentalChargeDecimal.ToString(<span style="color:#a31515; font-family:Times New Roman,serif; font-size:12pt "c"<span style="font-family:Times New Roman,serif; font-size:12pt )
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt TotalHoursLabel.Text = TotalHoursInteger.ToString(<span style="color:#a31515; font-family:Times New Roman,serif; font-size:12pt "n"<span style="font-family:Times New Roman,serif; font-size:12pt )
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt TotalRentalsLabel.Text = RentalsCountInteger.ToString(<span style="color:#a31515; font-family:Times New Roman,serif; font-size:12pt "n"<span style="font-family:Times New Roman,serif; font-size:12pt )
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt AverageChargesLabel.Text = AverageChargesDecimal.ToString<span style="color:#a31515 "c")
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Times New Roman,serif; font-size:12pt TotalChargesLabel.Text = TotalChargesDecimal.ToString(<span style="color:#a31515; font-family:Times New Roman,serif; font-size:12pt "c"<span style="font-family:Times New Roman,serif; font-size:12pt )
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt
<p style="line-height:normal; margin-bottom:0pt <span style="color:blue; font-family:Times New Roman,serif; font-size:12pt EndSub
<br/>
View the full article