Posts: 96
Threads: 39
Joined: Sep 2011
Reputation:
0
Hi all!
I have a little question about how to read a line that contains for example "blabla", it's just a part of the text so no complete match.
Thanks in advance! <!-- s8-) --><img src="{SMILIES_PATH}/icon_cool.gif" alt="8-)" title="Cool" /><!-- s8-) -->
Posts: 1,006
Threads: 111
Joined: Jul 2010
Reputation:
1
You sorta already have an answer in this thread:
<!-- l --><a class="postlink-local" href="http://bpforums.info/viewtopic.php?f=9&t=645">viewtopic.php?f=9&t=645</a><!-- l -->
If we just alter the code a little bit, we can get it to do exactly what you want!
[code2=vbnet]Public Function ReadLine(ByVal containing As String)
If (TextBox1.Text.Contains(containing)) Then
'Now, we need to find which line index contains the thing
Dim lineIndex As Integer = TextBox1.GetLineFromCharIndex(TextBox1.Text.IndexOf(containing))
'Now, let's return the line
Dim lines As New List(Of String)
lines.AddRange(TextBox1.Text.Split(vbNewLine))
Return lines.Item(lineIndex)
End If
End Sub[/code2]
And there you go! Now to get the entire line, you can simply do something like this:
[code2=vbnet]MsgBox(ReadLine("blabla"))[/code2]
Posts: 96
Threads: 39
Joined: Sep 2011
Reputation:
0
Thanks man, appreciate your help!