Home/ASP.NET Forums/.NET Languages/Visual Basic .NET/not getting right values from class

not getting right values from class [Answered]RSS

2 replies

Last post Feb 02, 2010 07:59 PM by asgradl84

"Object reference not set to an instance of an object"
  • asgradl84



    401 Points

    113 Posts

    Re: not getting right values from class

    Feb 02, 2010 07:59 PM|asgradl84|LINK

    I would change your function to something like this

    Public Shared Function GetRate(ByVal Address As String, ByVal City As String, ByVal ZipCode As String) As Double
    'here is my code to find exact taxrate based on address provided
    'to make it simple
    GetRate = .075
    End Function

    Then, since your function is shared, you would use it in your button event like so

    Dim theRate as Double
    theRate = SalesTaxRates.SalesTaxRate.FindTaxRate(theAddress, theCity, theZipcode) 

    Declaring the function shared means it can be called without an instance of the class. Ofcourse this also limits the function to use of Const variables and Shared Functions/Subs

  • ‹ Previous Thread|Next Thread ›