IEnumerable Option strict late binding issue

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


IEnumerable Option strict late binding issue


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."


spot1.row("XUNIT")





Can u edit your post to add code formatting
– Gauravsa
9 hours ago







What is the type of spot1 and spot2? Does that type have a member named row? When you type the dot after either of them, what options does Intellisense give you?
– jmcilhinney
9 hours ago




spot1


spot2


row





Ienumerable type and we just have selected Option strict to ON after that this issue came
– PrasadK
9 hours ago




1 Answer
1



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.


For Each spot1 In irregularWeldspots


Object



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 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.


Spot


spot1






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

wi5O24Oit4oEr6HO3mr1QS4,i,QWPGo5EJ4f,0KozrAeXO4qppvp,wRw2,130H1
TGGPUIG68hrCjfpv,KzGDOTkcdTAlGmJH0sD2 5aAI20w3g634SkxFEa0FZQeP1RDFe X4gB,z3 2r0 6ca,3T7uE9ki

Popular posts from this blog

Keycloak server returning user_not_found error when user is already imported with LDAP

PHP parse/syntax errors; and how to solve them?

Using generate_series in ecto and passing a value