Search code examples
vb.netvb6com-interopvb6-migration

How to find out if a VB6 control is indexed (control array) in .NET


I working on a VB.NET project to manipulate a VB6 form using COM Interop. Some of the controls on my VB6 form are indexed and some not, so calling ctl.Index fails on those that have no index. Is there a way to work out if a control is indexed?


Solution

  • In vb6 you can use the TypeName function - Control arrays will return type "Object", not the actual control type - like so:

    If TypeName(ctrl) = "Object" Then
      isControlArray = true
    End If