read textbox into array - vb2005

  • Thread starter Thread starter Kevin O'Brien
  • Start date Start date
K

Kevin O'Brien

Hello,

Can someone please tell me how to read a text box in to an array? What I
have in the text box is a string of 7 words seperated by spaces. I would
like to read each word into an array. Any help would be greatly
appreciated!

Thanks,
Kevin
 
Do you want each word to be in a seperate array or strings? or you want
each word to be in seperate array of chars? or do you want all words to
be in one array?

If you want all words to be in one array:

Dim StringArray() As String
StringArray = Me.TextBox1.Text.Split(" ")

you will have the following in the StringArray:

StringArray(0) = "Word1"
String Array(1) = "Word2"
StringArray(2) = "Word3"
String Array(3) = "Word4"
etc

If you want to convert them to char array, you can do the following:

Dim c() As Char = stringArray(0).toCharArray

you can have a 2-D char array and use a loop to populate them or delare
7 arrays.

I hope that help
 
Hi ahmed,

The first solution is exactly what I am looking for and it works great.

Thank you for your help and the quick response!

Kevin
 
Back
Top