+ Reply to Thread
Results 1 to 3 of 3

[SOLVED] Identifying Control type

  1. #1
    Graham Payne
    Guest

    [SOLVED] Identifying Control type

    Hi,
    When looping through all the controls collection on a form is there a
    property that can be examined to determine what type of control each control
    is?
    Graham



  2. #2
    Jim Cone
    Guest

    Re: Identifying Control type

    Graham,

    Two approaches.

    Regards,
    Jim Cone
    San Francisco, USA
    http://www.realezsites.com/bus/primitivesoftware

    Sub FindOutWhatKind()
    Dim Ctrl As MSForms.Control
    For Each Ctrl In UserForm1.Controls
    MsgBox TypeName(Ctrl)
    Next
    Set Ctrl = Nothing
    End Sub

    Sub FindOutWhatKind2()
    Dim Ctrl As MSForms.Control
    For Each Ctrl In UserForm1.Controls
    If TypeOf Ctrl Is MSForms.CheckBox Then
    MsgBox Ctrl.Name
    ElseIf TypeOf Ctrl Is MSForms.CommandButton Then
    MsgBox Ctrl.Name
    'more ElseIf
    End If
    Next
    Set Ctrl = Nothing
    End Sub
    '----------


    "Graham Payne" <g.payne3@btinternet.com>
    wrote in message
    news:dcCdnVh_hZ4ocavZRVnyhw@bt.com...
    Hi,
    When looping through all the controls collection on a form is there a
    property that can be examined to determine what type of control each control
    is?
    Graham



  3. #3
    Graham Payne
    Guest

    Re: Identifying Control type

    Jim,
    thanks for that it works atreat.
    Regards,
    Graham
    "Jim Cone" <jim.coneXXX@rcn.comXXX> wrote in message
    news:uAGQqhqWGHA.752@TK2MSFTNGP02.phx.gbl...
    > Graham,
    >
    > Two approaches.
    >
    > Regards,
    > Jim Cone
    > San Francisco, USA
    > http://www.realezsites.com/bus/primitivesoftware
    >
    > Sub FindOutWhatKind()
    > Dim Ctrl As MSForms.Control
    > For Each Ctrl In UserForm1.Controls
    > MsgBox TypeName(Ctrl)
    > Next
    > Set Ctrl = Nothing
    > End Sub
    >
    > Sub FindOutWhatKind2()
    > Dim Ctrl As MSForms.Control
    > For Each Ctrl In UserForm1.Controls
    > If TypeOf Ctrl Is MSForms.CheckBox Then
    > MsgBox Ctrl.Name
    > ElseIf TypeOf Ctrl Is MSForms.CommandButton Then
    > MsgBox Ctrl.Name
    > 'more ElseIf
    > End If
    > Next
    > Set Ctrl = Nothing
    > End Sub
    > '----------
    >
    >
    > "Graham Payne" <g.payne3@btinternet.com>
    > wrote in message
    > news:dcCdnVh_hZ4ocavZRVnyhw@bt.com...
    > Hi,
    > When looping through all the controls collection on a form is there a
    > property that can be examined to determine what type of control each
    > control
    > is?
    > Graham
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1