Reference to a select of objects
Hi all
I have a six windows, and on them I have there five objects ListBox but every have different names. e.g LstCity, LstNames, LstHouses, Lst Peoples and LstCars.
if I would like to execute the same on the all objects (on a one form) then I can this make so - using the loop: For…each O.K. I understand it
Code:
Option Explicit
Private Sub ClearListBox()
Dim ctl As Control
' Clear all the ListBoxes on a one form.
For Each ctl In Controls
If TypeOf ctl Is ListBox Then ctl.List = ""
Next ctl
End Sub
Private Sub cmdClear_Click()
ClearListBox
End Sub
However…..
I want to execute the same on at will chosen object only and on a one at will chose forms - when this form is actively obviously. How to make it? How to make one code for objects with different name, on a different forms?
will be usefully some example code
thank in advance
Re: Reference to a select of objects
Not quite sure what you mean as you have the code and logic so its only a matter of changing the control type, no?
Re: Reference to a select of objects
I'm thinking (after reading this several times) that the OP wants a single sub to clear all list boxes on a chosen form. So...
Code:
Public Sub ClearAllListBoxesInForm(F As Form)
Dim C As Control
' Clear all the ListBoxes on a one form.
For Each C In F.Controls
If TypeOf C Is ListBox Then C.List = ""
Next C
End Sub
Good Luck
Re: Reference to a select of objects
Hmm, that does sound logical.
Ps, did I just do a Mr Spock impression? :lol:
Re: Reference to a select of objects
Hi All:wave:
vb5prgrmr wrote:
I'm thinking (after reading this several times) that the OP wants a single sub to clear all list boxes on a chosen form. So...
I correct it - then it should be:
I'm thinking (after reading this several times) that the OP wants a single sub to clear - there NOT all list boxes on a chosen form. So...
.. So, I want a single sub to clear on at will chosen object ONLY, and on ANY chosen form
BTW:
Someone know, how to change the Language in my app? Any way?
I greet Tamgovb:wave:
Re: Reference to a select of objects
So you want to clear a specific list box from a general sub... Well then...
Code:
Public Sub ClearListBox(LB As ListBox)
LB.Clear
End Sub
Good Luck