Solved

# Parse array

Posted on 2011-10-03
331 Views
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
0
Question by:lrbrister

LVL 18

Expert Comment

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

Author Comment

lludden:
Not following for some reason

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

Something else missing?
0

Author Comment

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

Accepted Solution

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
``````
0

LVL 27

Expert Comment

Yo uare making it pretty confusing when you say you want have "1103"
and then you say you want  691 is = 9.
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

Author Comment

planocz:
I meant that the COLUMN following the 691...not the number
0

LVL 27

Expert Comment

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.

what you are looking for ...as in a const value
Is this all coming for a text data file or what.

0

Author Comment

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

LVL 96

Assisted Solution

That sounds like a simple string split by exclamation mark, and then evaluating the array elements for the expected values.
0

Author Closing Comment

Thanks,
Will submit final code shortly...but I AM reading what I need now
0

## Featured Post

### Suggested Solutions

Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
This article will show, step by step, how to integrate R code into a R Sweave document
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

#### Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!