VB Code:
Private Sub calculateButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles calculateButton.Click Dim discountDecimal, dailyRateDecimal, miRateDecimal As Decimal Dim chargeMiBoolean As Boolean Const NONE_DISCOUNT_Decimal As Decimal = 1D Const CORP_DISCOUNT_Decimal As Decimal = 0.95D Const INS_DISCOUNT_Decimal As Decimal = 0.9D Const COMPACT_DAILY_RATE_Decimal As Decimal = 26.95D Const COMPACT_MI_RATE_Decimal As Decimal = 0.12D Const MID_DAILY_RATE_Decimal As Decimal = 32.95D Const MID_MI_RATE_Decimal As Decimal = 0.15D Const LUXURY_DAILY_RATE_Decimal As Decimal = 50.95D Const LUXURY_MI_RATE_Decimal As Decimal = 0.2D If Me.noneRadioButton.Checked Then discountDecimal = NONE_DISCOUNT_Decimal chargeMiBoolean = True End If If Me.corporateRadioButton.Checked Then discountDecimal = CORP_DISCOUNT_Decimal chargeMiBoolean = False End If If Me.insuranceRadioButton.Checked Then discountDecimal = INS_DISCOUNT_Decimal chargeMiBoolean = True End If If Me.compactRadioButton.Checked Then dailyRateDecimal = COMPACT_DAILY_RATE_Decimal miRateDecimal = COMPACT_MI_RATE_Decimal End If If Me.midsizeRadioButton.Checked Then dailyRateDecimal = MID_DAILY_RATE_Decimal miRateDecimal = MID_MI_RATE_Decimal End If If Me.luxuryRadioButton.Checked Then dailyRateDecimal = LUXURY_DAILY_RATE_Decimal miRateDecimal = LUXURY_MI_RATE_Decimal End If Dim myCalc As New CalculationsClass(Decimal.Parse(Me.totalMiTextBox.Text), Integer.Parse(Me.daysRentedTextBox.Text), discountDecimal, chargeMiBoolean, dailyRateDecimal, miRateDecimal) Me.amountDueTextBox.Text = myCalc.AmountDue.ToString("C") Debug.WriteLine("Check number before passing") Debug.WriteLine("discount=" & discountDecimal.ToString()) Debug.WriteLine("TotalMi=" & totalMiTextBox.Text.ToString()) Debug.WriteLine("DailyRate=" & dailyRateDecimal.ToString()) Debug.WriteLine("MiRate=" & miRateDecimal.ToString()) Debug.WriteLine("DaysRented=" & daysRentedTextBox.Text.ToString()) End SubVB Code:
Public Class CalculationsClass Private discountDecimal, dailyRateDecimal, miRateDecimal, amountDecimal, discountApply As Decimal Private daysRentedInteger, totalMiInteger As Integer Private chargeMiInBoolean As Boolean Sub New(ByVal totalMiInInteger As Integer, ByVal daysRentedInInteger As Integer, ByVal discountInDecimal As Decimal, ByVal chargeMiInBoolean As Boolean, ByVal dailyRateInDecimal As Decimal, ByVal miRateInDecimal As Decimal) 'constructor method Discount = discountInDecimal TotalMi = totalMiInInteger DailyRate = dailyRateInDecimal MiRate = miRateInDecimal DaysRented = daysRentedInInteger If ((TotalMi / DaysRented) < 100) Or chargeMiInBoolean Then MiRate = 0 End If amountDecimal = Discount * ((DailyRate * DaysRented) + (TotalMi * MiRate)) Debug.WriteLine("Check number after passing") Debug.WriteLine("discount=" & Discount.ToString()) Debug.WriteLine("TotalMi=" & TotalMi.ToString()) Debug.WriteLine("DailyRate=" & DailyRate.ToString()) Debug.WriteLine("MiRate=" & miRate.ToString()) Debug.WriteLine("DaysRented=" & DaysRented.ToString()) End Sub Private Property Discount() As Decimal Get End Get Set(ByVal value As Decimal) discountDecimal = value End Set End Property Private Property TotalMi() As Integer Get End Get Set(ByVal value As Integer) totalMiInteger = value End Set End Property Private Property DailyRate() As Decimal Get End Get Set(ByVal value As Decimal) dailyRateDecimal = value End Set End Property Private Property DaysRented() As Integer Get End Get Set(ByVal value As Integer) daysRentedInteger = value End Set End Property Private Property MiRate() As Decimal Get End Get Set(ByVal value As Decimal) miRateDecimal = value End Set End Property Public ReadOnly Property AmountDue() As Decimal Get Return (amountDecimal) End Get End Property End Class
I can't seem to pass on the varibles. When I check the values of all the ones on the left of the "=" is zero, while the varibles on the right side of the "=" is the correct value.
VB Code:
Discount = discountInDecimal TotalMi = totalMiInInteger DailyRate = dailyRateInDecimal MiRate = miRateInDecimal DaysRented = daysRentedInInteger




Reply With Quote