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(ofd File.FileN ame)
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.
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(ofd
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.
Dim arr(iCounter) as String' or whatever value you want to store in array
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Arthur,
I get the following:
'New' cannot be used on a class that is declared 'MustInherit'.
What am I missing?
I get the following:
'New' cannot be used on a class that is declared 'MustInherit'.
What am I missing?
ASKER
Actuall, if I use this:
Dim MyArray as New ArrayList
It seems to work. Thanks!
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
Glad to be of assistance.
AW