Reputation: 25
Private Sub EvaluateDistanceBetweenIrregularSpots(irregularWeldspots As IEnumerable)
For Each spot1 In irregularWeldspots
spot1.row("XUNIT") Is Nothing Then Continue For...
Issues for spot1.row("XUNIT")
as "Option strict On disallows late binding."
Upvotes: 0
Views: 97
Reputation: 17845
The IEnumerable interface used in your code is not generic, which means that the type of objects in it are unknown.
When you do For Each spot1 In irregularWeldspots
the actual type of spot1 is unknown so the Object
type is assumed. There is no "row" property in class Object so that's why you get the error.
There are a couple of ways you can resolve the error. The preferred way would be to use the generic IEnumerable interface:
Private Sub EvaluateDistanceBetweenIrregularSpots(irregularWeldspots As IEnumerable(Of Spot))
For Each spot1 In irregularWeldspots
spot1.row("XUNIT") Is Nothing Then Continue For...
If you have a non-generic IEnumerable object, you can cast it to a generic IEnumerable easily:
Dim irregularWeldspots = enumerableObject.Cast<Spot>()
EvaluateDistanceBetweenIrregularSpots(irregularWeldspots) 'Now it works!
If for some reason you can't do this, you can always specify the type of the spot1 variable explicitely:
Private Sub EvaluateDistanceBetweenIrregularSpots(irregularWeldspots As IEnumerable)
For Each spot1 As Spot In irregularWeldspots
spot1.row("XUNIT") Is Nothing Then Continue For...
You can replace Spot
by the actual type of the spot1
variable.
Upvotes: 1