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

    Call label from string...


    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 & "L"

    So, i would like to be able something like:

    GetTheLabelFromString( & "L").visible = true

    Thanks for your help.

  2. #2
    Join Date
    Nov 2003
    Portland, OR
    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:
    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
    Phil Weber

    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
    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, 05:23 AM
  2. App Object
    By Rob Teixeira in forum .NET
    Replies: 15
    Last Post: 05-31-2002, 03:30 PM
  3. Writing in HKEY_LOCAL_MACHINE...Access is denied
    By Martin in forum VB Classic
    Replies: 22
    Last Post: 12-03-2001, 03:53 AM
  4. How do I detect an FTP timeout?
    By Julian Milano in forum VB Classic
    Replies: 0
    Last Post: 08-10-2000, 09:16 PM
  5. Database problems
    By Robert Rieth in forum VB Classic
    Replies: 1
    Last Post: 04-11-2000, 03: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
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

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