Link to home
Start Free TrialLog in
Avatar of swilli6926
swilli6926

asked on

Arrays

Take a look at the code below.

I am opening a text file and reading and counting the number of records.
---------------------------------------------------------------
        Dim FileName As System.IO.StreamReader
        Dim strOneLine, strFile As String
        Dim iCounter As Integer
       
        ofdFile.ShowDialog()
        FileName = New System.IO.StreamReader(ofdFile.FileName)
        strOneLine = FileName.ReadLine

        Do Until strOneLine = Nothing
            strFile += strOneLine & ControlChars.CrLf
            strOneLine = FileName.ReadLine
            iCounter += 1
        Loop

        FileName.Close()
----------------------------------------------------------------------------

what would be the best way to take the value of iCounter and create an array to store the results.
I am using iCounter to get the number of elements to set up my array.

thanks fo rthe help.
Avatar of iboutchkine
iboutchkine

Dim arr(iCounter) as String' or whatever value you want to store in array
ASKER CERTIFIED SOLUTION
Avatar of Arthur_Wood
Arthur_Wood
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of swilli6926

ASKER

Arthur,

I get the following:

'New' cannot be used on a class that is declared 'MustInherit'.

What am I missing?
Actuall, if I use this:

Dim MyArray as New ArrayList

It seems to work.  Thanks!
sorry about the confusion.  Glad to hear you figured it out.

Glad to be of assistance.

AW