The GetDlgCtrlID API, when passed a valid hWnd, returns a value that directly corresponds to the Index property of the Controls collection:
Private Declare Function GetDlgCtrlID Lib "user32" _ (ByVal hWnd As Long) As LongPrivate Sub Form_Load() Dim i As Long On Error Resume Next For i = 0 To Controls.Count - 1 Debug.Print Controls(i).Name, Debug.Print Controls(GetDlgCtrlID(Controls(i).hWnd) _ - 1).Name Next iEnd Sub
This loop, located in the Form_Load event of a form with a number of controls on it, loops through all the controls and prints the name of each windowed control twice, demonstrating that it has correctly located the control without looping through the control collection.