array problem.

Ace Master

Well-known member
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 dont exist to be with empty values like
 
If you check to see if a file exists, then it wont be hard to just fill an element of array with a zero.
Code:
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

its possible that the system cant 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