array problem.

Ace Master

Centurion
Joined
Aug 28, 2003
Messages
140
I have a loop for loading file(s) into one array.

Everything works fine if my files are in correct location. This problem appears when one or more files are not there and my application has a fatal error.

I made a function for check if my files are there and if not the application is closed without that big error (msgbox)

It is possible to read my files and the files that don't exist to be with empty values like “0”?

This because all the values are used for a chart and even I don't have one day values I want to see the rest of files on my chart.

Thanks
 
If you check to see if a file exists, then it won't be hard to just fill an element of array with a zero.
Visual Basic:
'see if the file exists
If System.IO.FIle.Exists("path") Then
    'read the file or do whatever you want to do with it
    Dim reader As New System.IO.StreamReader("path")
    '....
Else 'file does not exist
    'add a zero to your array, im assuming you are using an ArrayList
    yourarray.Add(0)
End If
Is this what you are looking for?
:)
 
hi.

Thanks for your answer, but I made a function to see if the files is there, and if not, I write a file with my necessary name with 0 values.

But...I have another problem.... :(

My files are generated by a system (automatically). This system must generate 15 values like:

1 0.5
2 2.8
.......
15 2.36

it's possible that the system can't generate all the values, and maybe I will have this:

1 0.5
2
3 0.58
....
15 2.36

If this happens is bad because I receive a failure message like: Cast from string "" to type 'Decimal' is not valid. ..because I use some conversion tools.

It is possible to fill my array with empty values? ..

Thanks
 
Back
Top