
Originally Posted by
warrenayen
VB Code:
For X = 0 To fromForm.Controls.Count - 1
If fromForm.Controls(X).ToString = "DropDownMessage.DropDownMsg" Then
fromForm.Controls(X).Dispose()
Exit For
End If
Next
That's what I did. I created a nifty control that does drop down messages from the bottom of another control. To check if it exists, I check that it's type (to string) = "whatever" and leave the loop when done...
fromForm is the form...BTW...
VB Code:
If TypeOf(fromForm.Controls(X)) Is DropDownMessage.DropDownMsg
would probably be better than checking against a string value. If the name every changes, this method would cause a syntax error and let you know right away. Using a string comparison leaves room for error.
This just goes for your example code, as far as the original thread poster, I would also do what RobDog suggested.