DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  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, 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

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links