Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String Array Storage Issue?

Status
Not open for further replies.

RH610

Programmer
Aug 7, 2001
152
US
I have a VB5 program that read a large, comma-delimited file using the input # command. For example:

for i = 1 to 12: input #1, S$(i): next

There are about 80 arrays of the above size, most of which are numeric.
After each line I redimension all the arrays.
Problem is that after x number of lines have been read I will find that an element of the array that should be null (i.e. nothing between 2 commas) contains something that looks like it came from some previous input. It's as if I have not cleared the arrays (although I have).

This code worked fine in Microsoft BASIC, but doesn't seem to in VB. Is there some type of memory or storage issue going on here? I don't know.

Thank You

 
Hi,

I tried to reproduce your situation and found nothing strange. I made a file (c:\map1.csv) with:
1,2,3,4,,6,7,8,9,10,11,12

and used this code to test it:

Option Base 1 'array starting with 1 in stead of 0

Sub Test()

Dim Values()

f = FreeFile
Open "C:\map1.csv" For Input As #f

For i = 1 To 12

ReDim Preserve Values(i)
Input #f, Value
Values(i) = Value

Next i

Close #f

End Sub

Best regards,

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top