Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Referring a VB control via its name in string format


Reply
 
Thread Tools Display Modes
  #1  
Old 06-22-2004, 05:29 AM
recaigirgin recaigirgin is offline
Freshman
 
Join Date: Jan 2004
Location: İstanbul
Posts: 26
Question Referring a VB control via its name in string format


Hi,
I have menu items of which names are as subMenu(0), subMenu(1), etc. on the main form. I can use the properties of these items such that subMenu(0).visible = true.
What I would like to do is, I have a string which is "subMenu(0)" and I want to use this string in order to refer my actual control subMenu(0), so that after getting the value of the string, I can perform the "subMenu(0).visible = true" operation.
Is there a way in VB?
__________________
Funny but not easy...
Reply With Quote
  #2  
Old 06-22-2004, 05:48 AM
bluelotus bluelotus is offline
Centurion
 
Join Date: Apr 2004
Posts: 172
Default

you can declare a variable as a Menu Control and then can use that variable instead

eg:

Code:
Dim mnuStr As Menu

then
Code:
set mnuStr = subMenu(0)

after this u can use "mnuStr.visible = true"

all the best...
Reply With Quote
  #3  
Old 06-22-2004, 06:33 AM
Zahartor Zahartor is offline
Junior Contributor
 
Join Date: Sep 2003
Location: Montreal, canada
Posts: 231
Default

you can use the function:
controls("putstring").objetProperty
Reply With Quote
  #4  
Old 06-22-2004, 06:42 AM
Zahartor Zahartor is offline
Junior Contributor
 
Join Date: Sep 2003
Location: Montreal, canada
Posts: 231
Default

for arrays:
Code:
'i have a textbox -> text1 Dim strName As String Dim intNumber As Integer strName = Left("text1(0)", Len("text1(0)") - 3) intNumber = CInt(Mid("text1(0)", Len("text1(0)") - 1, 1)) Controls(strName)(intNumber).Text = "chien"
Reply With Quote
  #5  
Old 06-22-2004, 06:54 AM
recaigirgin recaigirgin is offline
Freshman
 
Join Date: Jan 2004
Location: İstanbul
Posts: 26
Thumbs up Thx

Controls function worked fine. Thx a lot for yor help.

Quote:
Originally Posted by Zahartor
for arrays:
Code:
'i have a textbox -> text1 Dim strName As String Dim intNumber As Integer strName = Left("text1(0)", Len("text1(0)") - 3) intNumber = CInt(Mid("text1(0)", Len("text1(0)") - 1, 1)) Controls(strName)(intNumber).Text = "chien"
__________________
Funny but not easy...
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->