I have some little issues with syntax. I am used to C# and just started VB.NET. I am trying to do a while loop when it loops through the items from a list. What is the syntax that I am doing wrong?
While oResponse.outputControl.Items(i) <> Nothing
//Do something
End While
Don’t forget to increment your counter:
and if this is a reference type (you didn’t say, but it probably is), you can’t compare it to
Nothingwith the<>operator:But maybe what you really want is a For Each loop:
And one more thing: what’s with the hungarian wart in the
oResponsevariable? That style is no longer recommended, and Microsoft now even specifically recommends against it. VB.Net also has a feature called “Default properties” that just might make this even simpler. Pulling it all together (now including the ListItem type from your comment above):