Finding items in a popup control

I have a popup control that I fill with a list of vendor names, and use the RowTag to store the vendor’s database Id.

When this window opens in “edit” mode, I need it to default-select the vendor that matches the record.

I do it like this:

For index As Integer = 0 To PopupVendor.ListCount If PopupVendor.RowTag ( index ) = vendorShipment.Vendor.VendorId Then PopupVendor.ListIndex = index Exit End If Next

.Net has nice “find” features, and while I’m not really comparing one language to another, I just want to know if what I’ve done here is the ‘right’ way to do it.
I’m still very green with Xojo…

yes

well almost

For index As Integer = 0 To PopupVendor.ListCount-1

Thanks

Are you sure? I had expected ListCount to be zero based too, but when I write it out to the debug window, it says “2”. That would be 3 items for a zero based list wouldn’t it?

count is always “1-based”. I have 2 items. Item(0) and Item(1). Do not confuse count and index.

I am confused lol… that was a good comment though, thanks

xxxxCount is 1 to X where X is the actual number of items
xxxxIndex is 0 to X-1 indicating the location

thanks guys. I understand now.