1 Replies - 687 Views - Last Post: 05 June 2011 - 02:20 PM Rate Topic: -----

#1 nercvz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-June 11

List box (how to load only those lines that contain specific word)

Posted 05 June 2011 - 01:54 PM

(sorry if you can't understand some words, my English is very bad)

Hi,

I'm using this code to load a text file into list box.

 r = New IO.StreamReader(str)
                While (r.Peek() > -1)
                    ListBox1.Items.Add(r.ReadLine)
                End While
                r.Close()


But it loads the whole file into list box. I only want to load those lines of text that contain following number: 2008.

It doesn't matter if the "2008" is at the beginning, middle or the end of a line.


Can you please tell me what to do?

Is This A Good Question/Topic? 0
  • +

Replies To: List box (how to load only those lines that contain specific word)

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1057
  • View blog
  • Posts: 4,099
  • Joined: 02-July 08

Re: List box (how to load only those lines that contain specific word)

Posted 05 June 2011 - 02:20 PM

 Dim s As String = r.Readline
 If s.Contains (word) Then
  ' add to listbox.
 End If 

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1