Hi,
As you can see in the post bellow, idx seems like to come into play of your other attribute of your selector return more than one element.
You could however use a Find Children activity with a filter not including your aaname (so only classname) and use this type of expression under based out of FindIndex on the output of Find Children, it should return your the same value as the idx.
Cint(elems.ToList.FindIndex(Function(e) e.Get("aaname").toString = "youraaname"))+1
Let me know if you need more explanation/details
Cheers