Good day.

I wana know what is the code (VB 2008) to get line that contains selected data that the user want from notepad?

example: apple, red, 180
pear, green, 200
melon, yellow, 250

the user will type "apple" in the textbox and the msgbox will tell in which line "apple" is in... answer : 1

how it can be done? i'm sooo light headed thinking of this...PLS PLS!

here is a simple code for that:

Dim c As Integer = 1
        Dim sr As New System.IO.StreamReader("demo.txt")
        Dim line As String = String.Empty
        line = sr.ReadLine()

        Do While (Not line Is Nothing)

            If line.Contains(TextBox1.Text) Then
                Label1.Text = c.ToString()
            End If

            line = sr.ReadLine()
            c = c + 1
        Loop

if the item is found then the line number goes to label1..

Owh it is working completely! thank you very much sir! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.