Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Separating the contents of a textbox

Status
Not open for further replies.

Wire216

Technical User
Feb 15, 2006
18
US
I have a textbox that is used to enter multiple 2-digit numbers, separated by commas. I want to assign each 2-digit number to a separate string variable (or array element).

For example:

If the textbox contains "22,25,29,31" I want to have variables like these:

Str1 = "22"
Str2 = "25"
Str3 = "29"
Str4 = "31"

I'm sure the best way to do this would be with an array. I don't know how to go about it though.

Any help is greatly appreciated.
 
Wire216,
The array is probably the easiest because of the [tt]Split()[/tt] function:
Code:
Dim strValues() as String
strValues = Split(Me.TextBox,",")

Hope this helps,
CMP


(GMT-07:00) Mountain Time (US & Canada)
 
Looks great so far. How can I check to see how many elements there are in the array? I need to loop through and run some code for each one.
 
Have a look at the UBound function

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
It's all working now. Thanks for the help CautionMP and PHV.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top