J
John Perkins
I'm a newbie and this is for a school assignment. I've
created a class and assigned a property in the class, but
when I try to access the property, it says that option
strict disallows late binding. Please help!
Here is the code
Public Class PayTotal
Public Shared mdecCommission As Decimal
Sub New()
'Constructor with empty arguments
End Sub
Sub New(ByVal WeeklySales As Decimal)
'Assign property values
Me.WeeklySales = WeeklySales
End Sub
#Region "Properties"
Protected mdecWeeklySales As Decimal
Property WeeklySales() As Decimal
Get
WeeklySales = mdecWeeklySales
End Get
Set(ByVal Value As Decimal)
mdecWeeklySales = Value
End Set
End Property
Overridable ReadOnly Property Commission() As Decimal
Get
Commission = mdecCommission
End Get
End Property
#End Region
#Region "Methods"
Public Overridable Function TotalPay() As Decimal
'Calculate the pay for salesperson
Dim decTotalPay As Decimal
Const decBASE_PAY As Decimal = 250D
Const decCOMMISSION_RATE As Decimal = 0.15D
Const decSALES_QUOTA As Decimal = 1000D
If mdecWeeklySales > decSALES_QUOTA Then
mdecCommission = mdecWeeklySales *
decCOMMISSION_RATE
Else
mdecCommission = 0
End If
decTotalPay = decBASE_PAY + mdecCommission
End Function
#End Region
End Class
Here is where I call for the data:
mSupervisorPay = New SupervisorPayTotal(CInt
(txtWeeklySales.Text))
If mSupervisorPay.commission > 0 Then
lblCommission.Text = FormatCurrency
(mSupervisorPay.commission)
lblTotalPay.Text = FormatCurrency
(mSupervisorPay.totalpay)
Else
lblTotalPay.Text = FormatCurrency(mSupervisorPay.totalpay)
End If
Any help would be greatly appreciated.
created a class and assigned a property in the class, but
when I try to access the property, it says that option
strict disallows late binding. Please help!
Here is the code
Public Class PayTotal
Public Shared mdecCommission As Decimal
Sub New()
'Constructor with empty arguments
End Sub
Sub New(ByVal WeeklySales As Decimal)
'Assign property values
Me.WeeklySales = WeeklySales
End Sub
#Region "Properties"
Protected mdecWeeklySales As Decimal
Property WeeklySales() As Decimal
Get
WeeklySales = mdecWeeklySales
End Get
Set(ByVal Value As Decimal)
mdecWeeklySales = Value
End Set
End Property
Overridable ReadOnly Property Commission() As Decimal
Get
Commission = mdecCommission
End Get
End Property
#End Region
#Region "Methods"
Public Overridable Function TotalPay() As Decimal
'Calculate the pay for salesperson
Dim decTotalPay As Decimal
Const decBASE_PAY As Decimal = 250D
Const decCOMMISSION_RATE As Decimal = 0.15D
Const decSALES_QUOTA As Decimal = 1000D
If mdecWeeklySales > decSALES_QUOTA Then
mdecCommission = mdecWeeklySales *
decCOMMISSION_RATE
Else
mdecCommission = 0
End If
decTotalPay = decBASE_PAY + mdecCommission
End Function
#End Region
End Class
Here is where I call for the data:
mSupervisorPay = New SupervisorPayTotal(CInt
(txtWeeklySales.Text))
If mSupervisorPay.commission > 0 Then
lblCommission.Text = FormatCurrency
(mSupervisorPay.commission)
lblTotalPay.Text = FormatCurrency
(mSupervisorPay.totalpay)
Else
lblTotalPay.Text = FormatCurrency(mSupervisorPay.totalpay)
End If
Any help would be greatly appreciated.