CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2000
    Posts
    57

    How can we determine the type of a control in VB

    I need to determine the type of each control on the form. That is I need to check whether a control is commandButton or checkbox etc. Using the Controls collection I can traverse through all the controls on the form, but how can i check their types?

    Ali.


  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: How can we determine the type of a control in VB

    Use TypeOf(). Be sure to use Is for comparison.


    Dim aControl as Control
    for each aControl in Controls
    If TypeOf(aControl) is CommandButton then
    MsgBox aControl.Name
    End If
    next





Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured