Here’s how you can read your text text by each new row. Say for example, the set of textbox text is something like this
insurance
mortgage
house
life
finance
where each new line is triggered by an Enter/Return key.
If you try to debug textBoxName.text, Visual Studio debugger will show you a string of
“insurance mortgage house life finance” which will get most people think that the seperator between each line is simply a whitespace/ blank character (” “) and thus use textBoxName.text.split(” “) to get the text on each line, which is not true.
The right way is actually splitting based on vbCrLf, which is carriage return + line feed (\r\n)
You can try this as an example:
Dim str As String() = textBoxName.Text.Split(New [Char]() {CChar(vbCrLf)})
For Each s As String In str
MsgBox(s)
Next
sanket says
thanks 4 ur logic
Rohan says
We can also do like following, I checked it … it works perfect 🙂
tempArr = txtInfo.Text.Split(Environment.NewLine)
David says
Yup, that works too. Thanks!