vb.net label problem

Discussion in 'Programming General' started by matt_sells, Jan 22, 2012.

vb.net label problem
  1. Unread #1 - Jan 22, 2012 at 8:30 AM
  2. matt_sells
    Joined:
    Nov 28, 2011
    Posts:
    78
    Referrals:
    0
    Sythe Gold:
    0

    matt_sells Member

    vb.net label problem

    Code:
    Public Sub label(ByVal root As Control)
            For Each number As Control In root.Controls
                label(number)
                If TypeOf number Is Label Then
                    Using writer As StreamWriter = New StreamWriter("PATH", True)
                        writer.WriteLine(number)
                    End Using
                End If
            Next
        End Sub
    
    doing this gets me all the information of all the labels, as well as linklabels which I don't want. How can I filter out the linklabels?
     
  3. Unread #2 - Jan 22, 2012 at 8:59 AM
  4. Darthatron
    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    vb.net label problem

    Code:
    If number.GetType() = (New Label).GetType() Then
    That works, but I'm not sure it's the best way of doing it.

    EDIT:
    A little testing showed a faster way. You were close.
    Code:
    If TypeOf number Is Label And Not (TypeOf number Is LinkLabel) Then
     
  5. Unread #3 - Jan 22, 2012 at 8:40 PM
  6. matt_sells
    Joined:
    Nov 28, 2011
    Posts:
    78
    Referrals:
    0
    Sythe Gold:
    0

    matt_sells Member

    vb.net label problem

    thanks worked v well
     
< Diet Calculator | C program help >

Users viewing this thread
1 guest


 
 
Adblock breaks this site