![]() |
Calling an Object using variables (What am I doing wrong????)
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 *** |
Calling an Object using variables (What am I doing wrong????)
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 |
Calling an Object using variables (What am I doing wrong????)
Thank you very much for your help. That seems to do the trick. *** Sent via Developersdex http://www.developersdex.com *** |
All times are GMT +1. The time now is 05:28 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com