Click to See Complete Forum and Search --> : No default member found for type 'Integer'


laxwrestler27
03-15-2008, 02:10 AM
I'm trying to compare an integer to a integer on a binding source:

Dim a As Integer = pickup.PickUpID
Dim b As Integer = CInt(BindingSource.Current("PickUpID"))
If a = b Then...

On line 2 I get "No default member found for type 'Integer'"

I've tried to Integer.Parse it, and CINT it, and google it, yet no success.

Thanks for any help in advance.

Hack
03-15-2008, 03:41 AM
Assuming the underlaying binding source is a database field, what is the field type of "PickUpId"?

laxwrestler27
03-15-2008, 09:16 PM
Its an integer. And the first line works without any problems.

For some reason the data from the binding source doesn't want to compare. But when I check it is says {Integer}

JBourgeois
03-17-2008, 04:53 PM
First, you should have a variable to reference your BindingSource. The way the code is writte, it tries to reference the class directly. Current is not a Shared (static) property, so it cannot be call on the class.

Second, I have found with experience that direct assignment in a declaration does not always work. Have you tried this:

Dim b As Integer
b = CInt(variable.Current("PickUpID"))

CInt has also failed me a couple of time in the 6 years I have been working in .NET, while the Convert class always work. It is also preferred, since it is the .NET way, not the VB way, and can be used in all languages:

b = Convert.ToInt32(variable.Current("PickUpID"))