Jump to content

[VB] control type


Recommended Posts

Dim c As Control
For Each c In Me.Controls
If c.??? = FileListBox Then
   If c.ListCount > 0 Then
       MsgBox "pending files"
   End If
End If
Next

hey there,

i was wondering how we can check the type of the control

Link to comment
Share on other sites


For VB6

Dim c As Object
 For Each c In Me.Controls
    If TypeName(c) = "FileListBox" Then
       If c.ListCount > 0 Then
          MsgBox ("pending files")
       End If
    End If
 Nextt

For VB.NET (no filelistbox in .net, so I assume you are using VB6?)

Dim c As Object
For Each c In Me.Controls
  If TypeOf (c) Is ListBox Then
     If c.items.count > 0 Then
        MsgBox("pending files")
     End If
  End If
Next

Edited by dman
Link to comment
Share on other sites

thanks dman, i guess this should do it, i'll try it tomorrow at work.

delprat that wouldn't work, since not all controls have ListCount so it would be an invalid property <-- EDIT: errm nevermind that, didn't pay attention to Dim c as FileListBox it's worth a try thanks anyways

Edited by saprouzy
Link to comment
Share on other sites

Delprat's way is better if you are only checking for one type of control, like the filelistbox. If you are processing all of the controls then the generic "Dim as object" is more versitile.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...