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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Share numbers string 1

Status
Not open for further replies.

miho1

Technical User
Oct 22, 2002
78
BG
Hi All.

At me eat string type 0 88 354. Then there will be another of type 35 258 1 564 etc.
I want will share string in variables not marks and numbers
A=0
B=88
C=354

If were letters - each mark, one letter, and here two or three figure - one number
And I do not know as it to make.
At someone eats idea?

Miho
 
If I understand you correctly you can use the split function. Split your string on the space character.

Dim MyArray() as string
MyArray = Split("0 88 354"," ")

This will give you,

MyArray(0)="0"
MyArray(1)="88"
MyArray(2)="354"

You may then need to do a type conversion to make it a number.

If I misunderstood then please explain again.

Thanks and Good Luck!

zemp
 
Big Thank zemp.

It has worked.
But as it is understood how many MyArray have turned out
Because it is necessary to specify to cycle For Next to process them.

Miho
 
Use the following in the for Next,

For i = 0 to Ubound(MyArray)

This will start at zero(0) the first element and go until the last element or upper bound of the array. You can also use,

For i = LBound(MyArray) to Ubound(MyArray)

Thanks and Good Luck!

zemp
 
Remember johnmw's advise a couple of threads ago: always check if UBOUND(Array) > -1 after using the SPLIT function before processing the array elements.

If the original string was not splitted for whatever cause ( e.g. a nullstring) then there are no elements to be processed!!!

_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
Thanks zemp!!!!!

Very much to me has helped.

I shall not overlook.

Miho
 

>after using the SPLIT function before processing the array elements

or you can just use For/Each...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top