|
-
May 10th, 2009, 02:28 PM
#1
Thread Starter
Hyperactive Member
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
I know, I know, my English is bad, sorry .....
-
May 10th, 2009, 02:47 PM
#2
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?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 11th, 2009, 12:42 AM
#3
Frenzied Member
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
Option Explicit should not be an Option!
-
May 11th, 2009, 01:26 AM
#4
Re: Reference to a select of objects
Hmm, that does sound logical.
Ps, did I just do a Mr Spock impression?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 11th, 2009, 05:34 PM
#5
Thread Starter
Hyperactive Member
Re: Reference to a select of objects
Hi All
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
Last edited by Tamgovb; May 11th, 2009 at 05:42 PM.
I know, I know, my English is bad, sorry .....
-
May 11th, 2009, 10:59 PM
#6
Frenzied Member
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
Option Explicit should not be an Option!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|