Call label from string...


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Call label from string...

  1. #1
    Join Date
    Jan 2005
    Posts
    56

    Call label from string...

    Hi,

    I would like to do a "simple" thing. I tried to search but I don't know what to search.

    I have a lot of textboxes and labels. The labels has the same name than textboxes, only with a "L" at the end of the name:

    textbox1 -> textbox1L
    textbox2 -> textbox2L
    textbox3 -> textbox3L
    ...

    When I do some changes in textbox1, i would like to make some forecolor or visible changes to the label.

    I would like to "call" the label with a string, like textbox1.name & "L"

    So, i would like to be able something like:

    GetTheLabelFromString(textbox1.name & "L").visible = true


    Thanks for your help.

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    If you're using .NET 2.0, try this:

    Me.Controls(TextBox1.Name & "L").Visible = True

    If you're using .NET 1.1, try this:
    Code:
    Dim NameToFind As String = TextBox1.Name & "L"
    For Each ctl As Control In Controls
        If ctl.Name = NameToFind Then
            Dim lbl As Label = CType(ctl, Label)
            lbl.Visible = True
        End If
    Next
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Jan 2005
    Posts
    56
    Thanks for the information.

    It worked !

Similar Threads

  1. Re: App Object (fixes)
    By Rob Teixeira in forum .NET
    Replies: 129
    Last Post: 06-06-2002, 06:23 AM
  2. App Object
    By Rob Teixeira in forum .NET
    Replies: 15
    Last Post: 05-31-2002, 04:30 PM
  3. Writing in HKEY_LOCAL_MACHINE...Access is denied
    By Martin in forum VB Classic
    Replies: 22
    Last Post: 12-03-2001, 04:53 AM
  4. How do I detect an FTP timeout?
    By Julian Milano in forum VB Classic
    Replies: 0
    Last Post: 08-10-2000, 10:16 PM
  5. Database problems
    By Robert Rieth in forum VB Classic
    Replies: 1
    Last Post: 04-11-2000, 04:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center