Parse array

I have an array coming in with an exclamation point delimiter
col1!col2!col3!...etc
I want to read row by row and when col3 = "1103" set a variable and then ext sub
Larry Bristersr. DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lluddenCommented:
Public Function GetValue(myArray() As string) AS Integer
Dim ReturnRow as Integer = -1
For I = 0 to myarray.length - 1
if SubString(myarray(i),"!",2) = "1103" Then
     ReturnRow = i
     Exit For
End If
Return ReturnRow
End Function
0
Larry Bristersr. DeveloperAuthor Commented:
lludden:
Not following for some reason


I added in the missing "Next" but getting error on SubString.

Something else missing?
0
Larry Bristersr. DeveloperAuthor Commented:
lluden
In my array is a line of data

Zap/21-1!ext-queues!691!9!Up!Queue!691|t|||60!9549998888!!3!3!(None)

The array is delimited with the !

I want to set my variable = the columns 9548889999
 if the column with the 691 = 691
and if the number following the 691 is = 9
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

SammyHgCommented:
Hi lrbrister,

Here's the code,

Dim str As String() = New [String]() {"Zap/21-1!ext-queues!691!9!Up!Queue!691|t|||60!9549998888!!3!3!(None)", "bla bla"}
Dim resultVariable As String = ""
For Each line As String In str
	Dim columns As String() = line.Split(New Char() {"!"C}, StringSplitOptions.RemoveEmptyEntries)
	If columns(2) = "691" AndAlso columns(3) = "9" Then
		resultVariable = columns(7)		
		Exit For
	End If
Next

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
planoczCommented:
Yo uare making it pretty confusing when you say you want have "1103"
and then you say you want  691 is = 9.
Please define what your  array is holding.
what you are looking for ...as in a const value
Is this all coming for a text data file or what.

May be better to use Text regexpressions.
0
Larry Bristersr. DeveloperAuthor Commented:
planocz:
I meant that the COLUMN following the 691...not the number
My bad for an inadequate explanation.
0
planoczCommented:
sorry I am still not getting it. First I  would most likely change the delimiter to something  like a " | " and not a " ! " making it a little easier to read.

Please define what your  array is holding.
what you are looking for ...as in a const value
Is this all coming for a text data file or what.

0
Larry Bristersr. DeveloperAuthor Commented:
planocz:
I have no control o=ver the definition and how te array is delimited.

It is coming in from Asterisk.Net and I'm getting the inbound call "array" from the PBX system

All I need to do is look at columns 2 and 3 and see if they equal 691 and 9

0
Bob LearnedCommented:
That sounds like a simple string split by exclamation mark, and then evaluating the array elements for the expected values.
0
Larry Bristersr. DeveloperAuthor Commented:
Thanks,
Will submit final code shortly...but I AM reading what I need now
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.