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
lrbristerAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
SammyHgConnect With a Mentor Commented:
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
 
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
 
lrbristerAuthor Commented:
lludden:
Not following for some reason


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

Something else missing?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
lrbristerAuthor 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
 
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
 
lrbristerAuthor 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
 
lrbristerAuthor 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 LearnedConnect With a Mentor Commented:
That sounds like a simple string split by exclamation mark, and then evaluating the array elements for the expected values.
0
 
lrbristerAuthor Commented:
Thanks,
Will submit final code shortly...but I AM reading what I need now
0
All Courses

From novice to tech pro — start learning today.