Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting Textbox data into an Array: VB 2008

178 views
Skip to first unread message

GeekBoy

unread,
Oct 7, 2008, 5:02:03 PM10/7/08
to
I did not see another group for this so I presume this is the correct one to
ask such a question.

Anyway, I need to get data entered into a textbox and put it all into an
array. I have looked and cannot find such an example of how to accomplish
this.

What I am trying to do it type in a set of numbers (e.g. 10 20 30....) and
fill in an array with those numbers.

Thanks for any gudiance.

Jack Jackson

unread,
Oct 7, 2008, 6:30:14 PM10/7/08
to

The String.Split method will break up a string.

Dim nums() as String = textbox1.Text.Split(" "c)

James Hahn

unread,
Oct 7, 2008, 6:36:20 PM10/7/08
to
Do you mean that each line in the text box is going to be one element in the
array?

Dim s() = Split(TextBox1.Text, vbCrLf)

Or is it one line in the text box with mumbers separated by spaces?

Dim s() = Split(TextBox1.Text, " ")

"GeekBoy" <Gee...@discussions.microsoft.com> wrote in message
news:81F5C28D-FC16-44E1...@microsoft.com...

GeekBoy

unread,
Oct 7, 2008, 11:46:12 PM10/7/08
to

"Jack Jackson" <jjac...@cinnovations.net> wrote in message
news:kfone4dhs0q952bab...@4ax.com...


Thanks for the reply.

Here is what I got so far. I guess I need to do some more reading on this. I
really do not have the time at this moment.

Dim array = New Integer(0 To 15) {}
Dim j As Integer
Dim s() As String = Split(txtEnterArray.Text, " ")

For j = 1 To array.GetLength(0)
s(j) = array(j)

Next j

GB

James Hahn

unread,
Oct 8, 2008, 1:06:05 AM10/8/08
to
Dim array(15) as integer

Dim j As Integer
Dim s() As String = Split(txtEnterArray.Text, " ")

For j = 0 To S.Length - 1
array(j) = ctype(val(s(j)), Integer)
Next j

"GeekBoy" <nerd_r...@nerdythree.net> wrote in message
news:2990589F-5858-48AE...@microsoft.com...

Cor Ligthert[MVP]

unread,
Oct 8, 2008, 1:09:32 AM10/8/08
to

GeekBoy,

Why do you make it yourself so difficult.
Jack gave you the complete answer, that is all you need.

You asked about numbers, as you mean values by instance integers, you can do
after that.

\\
dim x(nums.length - 1) as integer
For i = 0 to nums.length - 1
x(i) = CInt(nums(x))
next
///

You have to check f the numbers are real a values, however that is again
another question.

Be aware the above code can contains typos because I typed it direct in this
message

Cor

"GeekBoy" <nerd_r...@nerdythree.net> schreef in bericht
news:2990589F-5858-48AE...@microsoft.com...

GeekBoy

unread,
Oct 8, 2008, 1:52:12 AM10/8/08
to

"Cor Ligthert[MVP]" <notmyfi...@planet.nl> wrote in message
news:19197851-39AA-4617...@microsoft.com...

>
> GeekBoy,
>
> Why do you make it yourself so difficult.
> Jack gave you the complete answer, that is all you need.
>
> You asked about numbers, as you mean values by instance integers, you can
> do after that.


Sorry, I do C++. This is actually easier in C++ than Visual "Basic" as no
conversion, flipping, manipulation, etc is needed. Just define the data
type and accept input.

>
> \\
> dim x(nums.length - 1) as integer
> For i = 0 to nums.length - 1
> x(i) = CInt(nums(x))
> next


Thanks for your input also.

GeekBoy

unread,
Oct 8, 2008, 2:04:00 AM10/8/08
to

"James Hahn" <jh...@yahoo.com> wrote in message
news:eeFDmOQK...@TK2MSFTNGP04.phx.gbl...

> Dim array(15) as integer
> Dim j As Integer
> Dim s() As String = Split(txtEnterArray.Text, " ")
>
> For j = 0 To S.Length - 1
> array(j) = ctype(val(s(j)), Integer)
> Next j


Thanks a lot John for th eextra help.

GB

vbStudent

unread,
Oct 18, 2008, 11:53:00 PM10/18/08
to
Dear All,

I want to sign textbox string data to array, each letter in one index.

i.e. if I write in the textbox vb.net .. I need to store store it in an
array as following
array(0)=v
array(1)=b
array(2)=.
array(3)=n
array(4)=e
array(5)=t

How can I do that .. please reply me soon.

Thanks for your cooperation

Jack Jackson

unread,
Oct 19, 2008, 1:06:58 AM10/19/08
to
String has a method ToCharArray:

textbox1.Text.ToCharArray()

0 new messages