Home All Groups Group Topic Archive Search About

read textbox into array - vb2005

Author
29 Jun 2006 3:08 PM
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

Author
29 Jun 2006 3:30 PM
Ahmed
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

Ahmed
Kevin O'Brien wrote:
Show quoteHide quote
> 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
Author
29 Jun 2006 3:56 PM
Kevin O'Brien
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



Show quoteHide quote
"Ahmed" <ahmed1***@gmail.com> wrote in message
news:1151595000.110009.311350@p79g2000cwp.googlegroups.com...
> 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
>
> Ahmed
> Kevin O'Brien wrote:
>> 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
>
Author
29 Jun 2006 4:15 PM
Ahmed
You are welcome :)

Kevin O'Brien wrote:
Show quoteHide quote
> 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
>
>
>
> "Ahmed" <ahmed1***@gmail.com> wrote in message
> news:1151595000.110009.311350@p79g2000cwp.googlegroups.com...
> > 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
> >
> > Ahmed
> > Kevin O'Brien wrote:
> >> 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
> >