473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

read textbox into array - vb2005

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
Jun 29 '06 #1
3 3575
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


Jun 29 '06 #2
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" <ah*******@gmail.com> wrote in message
news:11**********************@p79g2000cwp.googlegr oups.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

Jun 29 '06 #3
You are welcome :)

Kevin O'Brien wrote:
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" <ah*******@gmail.com> wrote in message
news:11**********************@p79g2000cwp.googlegr oups.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


Jun 29 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ProteusGak | last post by:
:confused: VB2005: I have a datagridview and a textbox. When a user clicks in the datagridview, I would like some or part of the data in the row to show up in the textbox. Any clues? Thank you, PG
4
by: Hector M Banda | last post by:
Hi all, I am working on a project where I have a set of textboxs and some butons and I would like to have a way of keeping the textboxes using an array to make easier my data input. THis is...
1
by: Ian Tedridge | last post by:
If I have 3 textboxes on a form plus 1 multiline textbox. How can I add the text from textbox 1 to 3 to the multiline textbox ? I can add the 3 textbox contents to one line of the multiline...
5
by: Ian Tedridge | last post by:
If I have 3 textboxes on a form plus 1 multiline textbox. How can I add the text from textbox 1 to 3 to the multiline textbox ? I can add the 3 textbox contents to one line of the multiline...
7
by: Milsnips | last post by:
Hi there, Can anyone help me out on this one? i want to read each line entered in a multiline textbox and store it into an array. I cant find any properties for this in the control, the only...
3
by: =?Utf-8?B?UmljaA==?= | last post by:
Hello, I selected BorderStyle = Fixed3D for a textbox on a form in VB2005, but the textbox looks flat. In VB2003 the textbox has the same borderStyle = Fixed3D and has a 3D appearance. Is it...
4
by: viv | last post by:
how do you trap keyboard codes for text box in VB2005 ? I'm looking for a code snippet to only allow numeric input in a text box (same as Key event in VB6, then use Keyascii to decide action) ...
1
by: RW | last post by:
Hello. I've been working w/ vb 6.0 for sometime now and have moved up to VS 2005 to create a application for a Windows CE 5.0 hand held device. I thought the transition would be easy, however the...
1
cindy2
by: cindy2 | last post by:
Hi, I have a VERY complex problem. I have posted it under Forums/Visual Basic, but I was strongley recommended to post it here. In VB2005 I need a 2D array with x*x elements. There are two cases: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.