PC Review


Reply
Thread Tools Rate Thread

Calling an Object using variables (What am I doing wrong????)

 
 
Superman
Guest
Posts: n/a
 
      24th Apr 2007
I was wondering if someone out there might know how I would be able to
do the following:

I have 3 ComboBoxes and 3 Labels that are named as follows

Label_1
Label_2
Label_3

ComboBox_1
ComboBox_2
ComboBox_3

I am trying to create a subroutine to go through a loop from 1-3 and
hide both the comboboxes and labels, but for some reason I can not use
variables to call an object. Any ideas how I could make this work?


here is my subroutine so far


sub removeitems ()

dim counter as integer
dim tag1 as string
dim tag2 as string
dim ctl as control

counter = 1
tag1 = "ComboBox_"
tag2 = "Label_"

do until counter = 3

ctl = tag1 & counter (I have also tried using Set ctl =)
ctl.visible = false
ctl = tag2 & counter
ctl.visible = false

counter = counter + 1

loop

end sub

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      24th Apr 2007
Controls on a userform?

Dim iCtr as long
for ictr = 1 to 3
me.controls("label_" & ictr).visible = false
me.controls("combobox_" & ictr).visible = false
next ictr

Superman wrote:
>
> I was wondering if someone out there might know how I would be able to
> do the following:
>
> I have 3 ComboBoxes and 3 Labels that are named as follows
>
> Label_1
> Label_2
> Label_3
>
> ComboBox_1
> ComboBox_2
> ComboBox_3
>
> I am trying to create a subroutine to go through a loop from 1-3 and
> hide both the comboboxes and labels, but for some reason I can not use
> variables to call an object. Any ideas how I could make this work?
>
> here is my subroutine so far
>
> sub removeitems ()
>
> dim counter as integer
> dim tag1 as string
> dim tag2 as string
> dim ctl as control
>
> counter = 1
> tag1 = "ComboBox_"
> tag2 = "Label_"
>
> do until counter = 3
>
> ctl = tag1 & counter (I have also tried using Set ctl =)
> ctl.visible = false
> ctl = tag2 & counter
> ctl.visible = false
>
> counter = counter + 1
>
> loop
>
> end sub
>
> *** Sent via Developersdex http://www.developersdex.com ***


--

Dave Peterson
 
Reply With Quote
 
Superman
Guest
Posts: n/a
 
      2nd May 2007

Thank you very much for your help. That seems to do the trick.

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HashTable stores whole object as Key NOT the result of calling GetHashCode on the object when you do myHashTable.Add? John Davis Microsoft Dot NET Framework 3 13th Apr 2006 02:31 PM
Calling a batch file in a Web Service using Process object, uses wrong user context. Bucky Pollard Microsoft C# .NET 1 27th Sep 2005 05:29 PM
Object Variables vs Pointers to Object Variables Jeremy S. Microsoft C# .NET 1 12th Sep 2005 09:06 AM
Calling another form's object event - error msg... object required =?Utf-8?B?bHA=?= Microsoft Access Forms 2 22nd Dec 2004 11:38 PM
Calling a COM Object with a VARIANT* param from C# just shows ref object varParam Dave Microsoft C# .NET 2 17th Nov 2003 09:35 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:21 PM.