A first chance exception of type 'System.NullReferenceException' occurred in BudgetSheet.exe An unhandled exception of type 'System.NullReferenceException' occurred in BudgetSheet.exe Additional information: Object reference not set to an instance of an object.
When I try to load items into my arrays. I have tried searching online and nothing so far has solved my problem. I just need these array to get loaded and then my code should all work properly.
this is where i define the arrays (m_strFiles and m_strCheck):
Option Explicit On
Option Strict On
Module modMain
Private m_strFilename As String
Private m_Files() As String
Private m_strCheck(,,) As String
Sub Main()
and this is the best example of the failing code:
Sub Load()
Dim di As New IO.DirectoryInfo(System.IO.Directory.GetCurrentDirectory & "\BudgetSheets\")
Dim diar1 As IO.FileInfo() = di.GetFiles()
Dim dra As IO.FileInfo
Dim x, y, z As Integer
Console.Clear()
Console.WriteLine(Space(4) & "**********")
Console.WriteLine(Space(4) & "***LOAD***")
Console.WriteLine(Space(4) & "**********")
Console.WriteLine()
For Each dra In diar1
x += 1
m_Files(x) = dra.ToString
Console.Write(x & ". ")
Console.Write(m_Files(x))
Console.Write(vbNewLine)
Next
Console.WriteLine()
Console.Write("Please select file to open: ")
x = CInt(Console.ReadLine)
m_strFilename = System.IO.Directory.GetCurrentDirectory & "\BudgetSheets\" & m_Files(x)
Dim StrSplit(2), LineRead As String
Dim sreReader As IO.StreamReader
sreReader = IO.File.OpenText(m_strFilename)
x = 0
y = 0
z = 0
Do
LineRead = sreReader.ReadLine
If LineRead = String.Empty Then
Console.WriteLine(m_strFilename & " loaded...")
Console.WriteLine()
Console.WriteLine("Press any key to continue...:")
Console.ReadLine()
Call Menu()
End If
StrSplit = LineRead.Split(CChar(","))
m_strCheck(x, y, z) = StrSplit(0)
y += 1
m_strCheck(x, y, z) = StrSplit(1)
z += 1
m_strCheck(x, y, z) = StrSplit(2)
x += 1
y = 0
z = 0
Loop Until sreReader.Peek = -1
sreReader.Close()
Console.WriteLine()
Console.WriteLine(m_strFilename & " loaded...")
Console.WriteLine()
Console.WriteLine("Press any key to continue...")
Console.ReadLine()
Call Menu()
End Sub
I'm sure that this situation must have been brought up somewhere but I have as of yet been unable to find it.

New Topic/Question
Reply



MultiQuote







|