2 Replies - 869 Views - Last Post: 28 September 2012 - 08:49 AM Rate Topic: -----

#1 rbox505  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 28-September 12

MyReader to Multi-diminsional Array

Posted 28 September 2012 - 08:38 AM

Hello everyone,

I am attempting to use the MyReader function to read data from a text file and populate a multidimensional array. What should be a simple task is really causing a huge headache. It seems to me that everthing I try continues to throw numerous can't convert to array-string exceptions and null reference exceptions. Any insight to what is going on would be greatly approciated.

While Not MyReader.EndOfData
                Try
                    currentRow = MyReader.ReadFields()
                    DataInTest.Text = "Data"

                    Dim currentField As String

                    For Each currentField In currentRow
                        Dim testArray As Decimal()
                        Dim arrayCount As Integer = 0

                        Debug.Print(currentField)
                        testArray.SetValue(currentField, arrayCount)
                        arrayCount = arrayCount + 1
                    Next
                Catch ex As Microsoft.VisualBasic.
                            FileIO.MalformedLineException
                    MsgBox("Line " & ex.Message &
                    "is not valid and will be skipped.")
                End Try



-rbox505

Is This A Good Question/Topic? 0
  • +

Replies To: MyReader to Multi-diminsional Array

#2 janne_panne  Icon User is offline

  • WinRT Dev
  • member icon

Reputation: 428
  • View blog
  • Posts: 1,047
  • Joined: 09-June 09

Re: MyReader to Multi-diminsional Array

Posted 28 September 2012 - 08:43 AM

What the heck is MyReader?
Was This Post Helpful? 0
  • +
  • -

#3 rbox505  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 28-September 12

Re: MyReader to Multi-diminsional Array

Posted 28 September 2012 - 08:49 AM

View Postjanne_panne, on 28 September 2012 - 08:43 AM, said:

What the heck is MyReader?



Janne,

Maybe I worded it wrong, just frustrated. Please see the code below for a better understanding... hopefully. Thank you for you insight on this.


Using MyReader As New Microsoft.VisualBasic.
                       FileIO.TextFieldParser("loanDataFile.txt")

            MyReader.TextFieldType = FileIO.FieldType.Delimited
            MyReader.SetDelimiters(",")

            Dim currentRow As String()

            While Not MyReader.EndOfData
                Try
                    currentRow = MyReader.ReadFields()
                    DataInTest.Text = "Data"

                    Dim currentField As String

                    For Each currentField In currentRow
                        Dim testArray As Decimal()
                        Dim arrayCount As Integer = 0

                        Debug.Print(currentField)
                        testArray.SetValue(currentField, arrayCount)
                        arrayCount = arrayCount + 1
                    Next
                Catch ex As Microsoft.VisualBasic.
                            FileIO.MalformedLineException
                    MsgBox("Line " & ex.Message &
                    "is not valid and will be skipped.")
                End Try

            End While

        End Using

    End Sub




The text document consist of the following:
0.0535, 7
0.055, 15
0.0575, 30

All I am needing to do is take these valuse and create a multi-dimensional array with them. Any thoughts?

-rbox505
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1