Adblock breaks this site

vb.net label problem

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

  1. matt_sells

    matt_sells Member

    Joined:
    Nov 28, 2011
    Posts:
    78
    Referrals:
    0
    Sythe Gold:
    0
    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?
     
  2. Darthatron

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0
    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
     
  3. matt_sells

    matt_sells Member

    Joined:
    Nov 28, 2011
    Posts:
    78
    Referrals:
    0
    Sythe Gold:
    0
    vb.net label problem

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


 
 
Adblock breaks this site