-2

I got the data from a text file as follows:

KILL
MAD
JOG
JUG

From the above data I want to put the text "Kill" in Textbox 1, the text "MAD" in textbox 2, the text "JOG" in the textbox 3, and "JUG" in the textbox 4 The following screenshot

Click Here

So, anyone can help me ?

LukmanH
  • 13
  • 1
  • 3
  • 5
  • _"and continuous"_ ask one question in each question. By modifying your questions you make all answers that were correct at the time they were posted now incorect. Also, if you have multiple lines how do you want to show them in a single pair of textboxes? You should consider to use a different control like `DataGridView`. – Tim Schmelter Nov 14 '14 at 10:36
  • possible duplicate of [Splitting a string at all whitespace](http://stackoverflow.com/questions/1562981/splitting-a-string-at-all-whitespace) – Bjørn-Roger Kringsjå Nov 15 '14 at 08:59

2 Answers2

1

You can use String.Split:

Dim text As String = File.ReadAllText(path)
Dim bothTokens As String() = text.Split() ' uses white-space characters as delimiter
textboxt1.Text = bothTokens(0) ' or bothTokens.First()
textboxt2.Text = bothTokens(1) ' or bothTokens.Last()

This splits by all white-space characters(also by new-line or tab), if you only want to split by space use text.Split(" "c) instead of Split().

Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939
0

Try

Dim s As String = "KILL09 fre0912"
Dim parts As String() = s.Split(New Char() {" "c})
textBox1.Text = parts(0)
textBox2.Text = parts(0)
Think Different
  • 2,815
  • 1
  • 12
  • 18