0
如何獲取文本框中的指定行並從該行中獲取文本中的文本如何在文本框中找到指定的行
如何獲取文本框中的指定行並從該行中獲取文本中的文本如何在文本框中找到指定的行
您需要將文本框文本拆分爲基於行的字符串數組分離,然後,如果你有足夠的線,從陣列獲取行:
Dim asLines As String()
Dim wLineToGet As Integer = 2
asLines = TextBox1.Text.Split(New String() {Environment.NewLine}, StringSplitOptions.None)
If asLines IsNot Nothing AndAlso asLines.Length >= wLineToGet Then
MessageBox.Show("Line " & wLineToGet & " = " & asLines(wLineToGet - 1))
Else
MessageBox.Show("There are not enough lines in the textbox to retrieve line " & wLineToGet)
End If
Dim lines As String() = testing.Text.Split(Environment.NewLine)
然後訪問線就這樣
lines(0) // would be first line
如果您使用其中的一個作爲您的答案,則放置一個綠色的選中標記,這將有助於您的接受評級。 – 2012-08-09 22:22:49