• Log in or sign up for an account here: https://www.sythe.org/login

vb.net label problem

matt_sells

Member
Joined
Nov 28, 2011
Sythe Gold
0
Messages
78
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?
 
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?

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
 
duelarena.gg
Back
Top