Question

I tried alot of things but it never worked :/ On my site, there's a list of the "10 newest members". I'm trying to do a new "orange" member notification on my application. There is white, grey and orange new members. For now I found how to get the source code of the newest orange members on my site with this : (RichTextBox1 is where my site sourcecode is)

            Dim list As New List(Of String)
            For Each line In RichTextBox1.Lines
                If line.Contains("255, 153, 51") Then
                    list.add(line)
                End If
            Next

This is giving me all the new members in orange, but now I'm trying to do that whenever there's a NEW name on that list, it will notify us. I tried to put it all the orange names in one string and that whenever the string is different than before, it will notify us but the problem is that it notify us if there's orange name that disappear from the list, and I want to know when there's a NEW member on the list.

I hope you can understand :P

Thanks in advance!

Was it helpful?

Solution

The easiest way is to use a HashSet<String> here. This can record all of the namse you've seen before and hence make it easy to determine when a new one is added.

Class TheClass
  Dim seen As New HashSet(Of String)()

  Sub TheFunction()
    Dim list As New List(Of String)
    For Each line In RichTextBox1.Lines
      If line.Contains("255, 153, 51") AndAlso Not seen.Contains(line) Then
         list.Add(line)
         seen.Add(line)
      End If
    Next
  End SUb
End Class

Now the list type will only contain newly seen values

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top