10-24-2012, 08:23 PM
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]
<!-- 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]