user279521
user279521

Reputation: 4807

Class 'clsGetHeaderValue' cannot be indexed because it has no default property

I am getting a strange error when I try to build my solution. The error occurs when I am calling the oGetHeaderValue function and passing the parameters.

Dim oGetHeaderValue As New clsGetHeaderValue

Dim returnString As String
returnString = oGetHeaderValue(strInvoiceNumber, strOrderNumber)

The error message is: Class 'clsGetHeaderValue' cannot be indexed because it has no default property.

Upvotes: 2

Views: 15009

Answers (2)

Darrel Lee
Darrel Lee

Reputation: 2470

The confusion is caused by the fact that VB.Net uses () for array indexing as well as method calls.

Upvotes: 2

Hans Olsson
Hans Olsson

Reputation: 55039

You're calling your instance oGetHeaderValue as if it's a method. It looks like you probably meant to call a function on it instead but missed out that bit. So maybe your code should be:

Dim returnString As String = oGetHeaderValue.YourMethod(strInvoiceNumber, strOrderNumber)

Where YourMethod is whatever method you wanted to call.

And just to clarify after reading your question again, oGetHeaderValue is not a function, it's an instance of a class that might contain functions and subs etc.

Upvotes: 7

Related Questions