saprouzy Posted June 28, 2005 Share Posted June 28, 2005 Dim c As ControlFor Each c In Me.ControlsIf c.??? = FileListBox Then If c.ListCount > 0 Then MsgBox "pending files" End IfEnd IfNexthey there, i was wondering how we can check the type of the control Link to comment Share on other sites More sharing options...
dman Posted June 28, 2005 Share Posted June 28, 2005 (edited) For VB6Dim 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 ObjectFor Each c In Me.Controls If TypeOf (c) Is ListBox Then If c.items.count > 0 Then MsgBox("pending files") End If End IfNext Edited June 28, 2005 by dman Link to comment Share on other sites More sharing options...
Delprat Posted June 28, 2005 Share Posted June 28, 2005 Another solution (faster if many controls) :Dim c As FileListBoxFor Each c In Me.Controls If c.ListCount > 0 Then MsgBox "pending files" End IfNextbye Link to comment Share on other sites More sharing options...
saprouzy Posted June 28, 2005 Author Share Posted June 28, 2005 (edited) 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 June 28, 2005 by saprouzy Link to comment Share on other sites More sharing options...
dman Posted June 28, 2005 Share Posted June 28, 2005 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 More sharing options...
saprouzy Posted June 29, 2005 Author Share Posted June 29, 2005 delprat's way didn't work ,am getting type mismatch when the c is assigned a control that isn't a filelistbox during the for loop.am sticking to dman's way.thanks both Link to comment Share on other sites More sharing options...
Delprat Posted June 29, 2005 Share Posted June 29, 2005 Sorry for the bad I haven't used VB since years... Link to comment Share on other sites More sharing options...
saprouzy Posted June 29, 2005 Author Share Posted June 29, 2005 no worries dude thanks for your help Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now