Split

gomindi

Freshman
Joined
Aug 28, 2002
Messages
25
Location
UT
Here is an example of my code:

Dim items() As String
Dim s As String = nreader.ReadToEnd
items = s.Split(New Char() {"|"c})
Dim anItem As String
For Each anItem In items

Here is where I am having a problem. I want the split information to show in individual text boxes. I don't know how to make this happen. Any clues?


Next

Thanks!
Mindi
 
Are these textboxes already set up?

If not, you could initialize, populate and display textboxes on-the-fly in your loop, like so:

Visual Basic:
t = New TextBox()
t.Text = "the text for this item"
t.Location = New Point(100, 100) 'Would have to vary throughout the loop
Controls.Add(t)
 
Thank you so much for that info. It was really helpful. I have one more question, how would I get this loop to continue to run and create these text boxes on the fly until it has finished reading my text file?
 
You posted some code above with the beginning of a loop, I assumed you would put it in that one. Just above that, with the other declarations you would declare t as type textbox, then go through adding them.

Something like this, maybe?

Visual Basic:
Dim items() As String
Dim s As String = nreader.ReadToEnd 
items = s.Split(New Char() {"|"c})
Dim anItem As String
Dim t As TextBox

For Each anItem In items
  t = New TextBox()
  t.Text = anItem
  t.Location = New Point(100, 20 * items.IndexOf(anItem)) 'Would have to vary throughout the loop
  Controls.Add(t)
Next
 
Back
Top