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!

Split() question 1

Status
Not open for further replies.

kencat742

Programmer
Jun 30, 2005
23
US
Each line of my textbox is an array which is read from an excel file. In the text box it looks somewhat like this where all the pump commands are in one column and the different valve commands are in their columns:

Pump /Z Valve /Y Valve
SLEW = 5000 GO5 GO15
VM = 5000 GO9 GO16
MOVR = -5000 GO6 GO12
SSTP GO8 GO15
SLEW = 50 GO5 GO16

What I want to do is go through the array to get each value seprarately using the Split function at chr(9) which I used for spacing in the txtbox. Some of the lines have more than one chr(9) between the columns (such as between SSTP and GO8). In this case what will happen with the split? will it have an element in the array which is blank or will it skip over both chr(9)? Thanks :)

You've heard about the computer programmer that died while washing his hair in the shower. The instructions said, 'Lather, rinse, repeat.'
 
It will have a blank entry. You could

myArray(n) = Replace ( myArray(n), Chr(9) & Chr(9), Chr(9))

Then do the split. That should replace double occurrences of chr(9) with a single occurrence. You could get a little fancier with
Code:
nLen = 0
Do Until nLen = Len(myArray(n))
    nLen = Len(myArray(n))
    myArray(n) = Replace ( myArray(n), Chr(9) & Chr(9), Chr(9))
Loop
which should remove all multiple occurrences.
 
Thanks, the replace works great :)
This makes my for/next loop look a lot prettier (and my code a lot less complicated)

You've heard about the computer programmer that died while washing his hair in the shower. The instructions said, 'Lather, rinse, repeat.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top