Multidimensional arrays & Parsing

N

Necromis

I am trying to figure out a way to change the below code to store data
in a multidemensional array rather than a listbox. The reason being is
I need to be able to pull each "currentrow" and manipulate the
position of each "currentfield" to then imput this data to another
source as a string. The delimited text might look like the following.

acctno, name, expdate,cr_line
4428123456789012,smith,0807,5000
4428123456789025,williams,0908,15000

I then would need to manipulate this into a string like this.....

NM*014*4428123456789012*0807

I have no trouble with the NM*014* pieces as these would be constants
but thought if I could put these items into a multidimensional array I
could call them out easier within a for next loop.

Like this.....

dim output as string

output = "nm*014*' & acct(1,0) & "*" & acct(1,2)

........So any help in accomplishing this would be VERY Helpful.


Private Sub LoadCommaDelimetedTextFileIntoListBox(ByVal filePath As
String)

Dim theTextFieldParser As TextFieldParser

theTextFieldParser =
My.Computer.FileSystem.OpenTextFieldParser(filePath)

theTextFieldParser.TextFieldType =
Microsoft.VisualBasic.FileIO.FieldType.Delimited

theTextFieldParser.Delimiters = New String() {","}

Dim currentRow() As String
Try
While Not theTextFieldParser.EndOfData

currentRow = theTextFieldParser.ReadFields()

Dim currentField As String

For Each currentField In currentRow
Me.ListBox1.Items.Add(currentField)
Next
End While
Catch malFormLineEx As
Microsoft.VisualBasic.FileIO.MalformedLineException
MessageBox.Show("Line " & malFormLineEx.Message & "is not
valid and will be skipped.", "Malformed Line Exception")
Catch ex As Exception
MessageBox.Show(ex.Message & " exception has occurred.",
"Exception")
Finally
theTextFieldParser.Close()
End Try
 
G

GS

I don't think I read the question fully but you want to split string
variable s delimited by comma
into array
dim sArray as String[]

sArray = s.split{",")

I am sure you figure out how to use this tidbit to plug in the value into
you multi-dimensional array if you still think that is the best way.
 
Top