A
AlBruAn
I have four classes named CheckVoucherReason, WriteOffReason,
CheckVoucherApproval and WriteOffApproval. In CheckVoucherApproval's
function to load values from the db prior to displaying them in the UI, I
make a call to a public shared function in CheckVoucherReason to return the
verbose description based on the reason ID; the call works as planned. In
WriteOffApproval's function to load values from the db, I'm attempting to
make a call to a public shared function in WriteOffReason to return the
verbose description of the reason; however, in this case it won't even
compile. Instead, I'm getting a "Cannot refer to an instance member of a
class from within a shared method or shared member initializer without an
explicit instance of the class" error message.
My function in CheckVoucherReason is defined as:
Public Shared Function RetrieveByID(ByVal reasonID As Integer) As
CheckVoucherReason
My function in WriteOffReason is defined as:
Public Shared Function RetrieveByID(ByVal reasonID As Integer) As
WriteOffReason
So, they are essentially the same ... differing only in what they return.
My call to the CheckVoucherReason function is:
Dim reason As String = CheckVoucherReason.RetrieveByID(reasonID) contained
within a public shared function in CheckVoucherApproval.
My call to the WriteOffReason function is:
Dim reason As String = WriteOffReason.RetrieveByID(reasonID) contained
within a public shared function in WriteOffApproval.
Usage of the CheckVoucherApproval class or the WriteOffApproval class is
made by the web page the user has displayed.
So, my question is this: why does the function call for WriteOffApproval
throw an error while the function call for CheckVoucherApproval doesn't?
Logically, either both should work or both should fail, but that's apparently
not the case here.
CheckVoucherApproval and WriteOffApproval. In CheckVoucherApproval's
function to load values from the db prior to displaying them in the UI, I
make a call to a public shared function in CheckVoucherReason to return the
verbose description based on the reason ID; the call works as planned. In
WriteOffApproval's function to load values from the db, I'm attempting to
make a call to a public shared function in WriteOffReason to return the
verbose description of the reason; however, in this case it won't even
compile. Instead, I'm getting a "Cannot refer to an instance member of a
class from within a shared method or shared member initializer without an
explicit instance of the class" error message.
My function in CheckVoucherReason is defined as:
Public Shared Function RetrieveByID(ByVal reasonID As Integer) As
CheckVoucherReason
My function in WriteOffReason is defined as:
Public Shared Function RetrieveByID(ByVal reasonID As Integer) As
WriteOffReason
So, they are essentially the same ... differing only in what they return.
My call to the CheckVoucherReason function is:
Dim reason As String = CheckVoucherReason.RetrieveByID(reasonID) contained
within a public shared function in CheckVoucherApproval.
My call to the WriteOffReason function is:
Dim reason As String = WriteOffReason.RetrieveByID(reasonID) contained
within a public shared function in WriteOffApproval.
Usage of the CheckVoucherApproval class or the WriteOffApproval class is
made by the web page the user has displayed.
So, my question is this: why does the function call for WriteOffApproval
throw an error while the function call for CheckVoucherApproval doesn't?
Logically, either both should work or both should fail, but that's apparently
not the case here.