I have written the code and I am new to working with classes. If someone could point me in the right direction I think I can figure it out. I looked at MSDN and learned this much, so maybe I didn't get the right understanding but I thought I would give it a try. When I run the application I use a combobox to select option 1 or option 2 , however this results in an error.

Here is the code:

Imports System.IO

Class Transaction
    Private m_prevBal As Double
    Private m_date As Date                                  'Today's date = CStr(Today) 
    Private m_creditDebit As String                         'Deposit or Withdrawl 
    Private m_amount As Double                              'Amount for the transaction 
    Private m_checkOrSave As String                         'Checking or Savings 
    Public Property TransactionDate() As Date               'Date of transaction being made 
        Get
            Return m_date
        End Get
        Set(ByVal value As Date)
            m_date = value
        End Set
    End Property
    Public Property DepoOrWith() As String                  'Deposit or Withdrawl (for both checking and savings)-->DESCRIPTION of transaction 
        Get
            Return m_creditDebit
        End Get
        Set(ByVal value As String)
            m_creditDebit = value
        End Set
    End Property
    Public Property TransactionAmount() As Double           'Amount on transaction attempting to complete 
        Get
            Return m_amount
        End Get
        Set(ByVal value As Double)
            m_amount = value
        End Set
    End Property
    Public Property AcctName() As String                    'Checking or Savings account 
        Get
            Return m_checkOrSave
        End Get
        Set(ByVal value As String)
            m_checkOrSave = value
        End Set
    End Property
    Public Property PreviousBalance() As Double
        Get
            Return m_prevBal
        End Get
        Set(ByVal value As Double)
            m_prevBal = value
        End Set
    End Property
    Public ReadOnly Property NewBalance() As Double
        Get
            If m_creditDebit = "Deposit" Then           'Need to somehow inclued the transfer from and check clearings.
                NewBalance = m_prevBal + m_amount
                Return NewBalance
            ElseIf m_creditDebit.ToLower = "Withdrawl" Then
                NewBalance = m_prevBal - m_amount
                Return NewBalance
            End If
        End Get
    End Property
End Class
Class Account
    Private m_Balance As Double                         'Balance for either checking or savings 
    Private m_Savings As Account
    Private m_transSet() As Transaction
    Private m_Checking As Account
    Dim fileInput() As String
    Public Event negativeBalance(ByVal m_balance As Double)
    Public Event approvedTransaction()
    Public Property SavAccount() As Account
        Get
            Return m_Savings
        End Get
        Set(ByVal value As Account)
            m_Savings = value
        End Set
    End Property
    Public Property CheckAccount() As Account
        Get
            Return m_Checking
        End Get
        Set(ByVal value As Account)
            m_Checking = value
        End Set
    End Property
    Public ReadOnly Property Balance() As Double
        Get
            Return m_transSet(m_transSet.Length - 1).NewBalance
        End Get
    End Property
    Public WriteOnly Property transDate() As Date
        Set(ByVal value As Date)
            m_transSet(0).TransactionDate = value
        End Set
    End Property
    Public WriteOnly Property Description() As String
        Set(ByVal value As String)
            m_transSet(1).DepoOrWith = value
        End Set
    End Property
    Public WriteOnly Property Amount() As Double
        Set(ByVal value As Double)
            m_transSet(2).TransactionAmount = value
        End Set
    End Property
    Public WriteOnly Property AccountName() As String
        Set(ByVal value As String)
            m_transSet(3).AcctName = value
        End Set
    End Property
    Sub ReadFile(ByVal NameofAccount As String, ByRef listDisplay As ListBox)
        Dim fmtStr As String = "{0,-10} {1,-30}{2,20:c} {3, 10}"
        Dim tran As Transaction
        Dim x As Integer = 0
        Dim sr As StreamReader = Nothing
        If NameofAccount = "Savings" Then
            sr = File.OpenText("csvSAVINGS.TXT")
        Else                                            'If NameofAccount = "Checking" Then 
            sr = File.OpenText("csvCHECKING.TXT")
        End If
        Do While (sr.Peek <> -1)
            tran = New Transaction
            fileInput = sr.ReadLine.Split(","c)
            tran.TransactionDate = fileInput(0)
            tran.DepoOrWith = fileInput(1)
            tran.TransactionAmount = fileInput(2)
            tran.PreviousBalance = fileInput(3)
            ReDim Preserve m_transSet(x)
            m_transSet(x) = tran
            listDisplay.Items.Add(String.Format(fmtStr, tran.TransactionDate.ToShortDateString, tran.DepoOrWith, _
            FormatCurrency(tran.TransactionAmount) & " PREV BAL", FormatCurrency(tran.PreviousBalance) & _
            " New BAL" & FormatCurrency(tran.NewBalance)))
            x += 1
            tran = Nothing
        Loop
        sr.Close()
    End Sub
    Function CalcBalance(ByVal activity As Transaction) As Double
        Dim tran As Transaction
        Dim x As Integer = -1
        Dim sr As StreamReader = Nothing
        If activity.AcctName = "Savings" Then
            sr = File.OpenText("csvSAVINGS.TXT")
        ElseIf activity.AcctName = "Checking" Then
            sr = File.OpenText("csvCHECKING.TXT")
        End If
        Do While (sr.Peek <> -1)
            tran = New Transaction
            fileInput = sr.ReadLine.Split(","c)
            tran.TransactionDate = fileInput(0)
            tran.DepoOrWith = fileInput(1)
            tran.TransactionAmount = fileInput(2)
            tran.PreviousBalance = fileInput(3)
            ReDim Preserve m_transSet(x)
            m_transSet(x) = tran
            x += 1
            tran = Nothing
        Loop
        sr.Close()
        If Balance <= 0 Then
            RaiseEvent negativeBalance(Balance)
        Else
            RaiseEvent approvedTransaction()
        End If
        Return Balance
    End Function
    Sub WriteTransaction(ByVal activity As Transaction)
        CalcBalance(activity)
        Dim temp() As String = {activity.TransactionDate & "," & activity.DepoOrWith.ToString & "," & _
        activity.TransactionAmount & "," & Balance}
        Select Case activity.AcctName
            Case Is = "Savings"
                Dim sw As StreamWriter = File.AppendText("csvSAVINGS.TXT")
                sw.WriteLine(Join(temp, ","))
                sw.Close()
            Case Is = "Checking"
                Dim sw As StreamWriter = File.AppendText("csvCHECKING.TXT")
                sw.WriteLine(Join(temp, ","))
                'RaiseEvent approvedTransaction(temp(0)) 
                sw.Close()
            Case Is = "Transfer to Checking"
                Dim sw1 As StreamWriter = File.AppendText("csvCHECKING.TXT")
                Dim sw2 As StreamWriter = File.AppendText("csvSAVINGS.TXT")
                Dim temp2() As String = {activity.TransactionDate & "," & activity.AcctName & "," & activity.TransactionAmount}
                sw1.WriteLine(Join(temp, ","))
                sw2.WriteLine(Join(temp2, ","))
                sw1.Close()
                sw2.Close()
            Case Is = "Transfer to Savings"
                Dim sw1 As StreamWriter = File.AppendText("csvSAVINGS.TXT")
                Dim sw2 As StreamWriter = File.AppendText("csvCHECKING.TXT")
                Dim temp2() As String = {activity.TransactionDate & "," & activity.AcctName & "," & activity.TransactionAmount}
                sw1.WriteLine(Join(temp, ","))
                sw2.WriteLine(Join(temp2, ","))
                sw1.Close()
                sw2.Close()
        End Select
    End Sub
End Class
Public Class form1
    Dim calc As Account
    Dim activity As Transaction
    Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'txtDate.Text = CStr(Today)                          'Displays today's date 
        ' lblTo.Visible = False
    End Sub

 
    Private Sub btnDeposit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeposit.Click
        'Sends all deposit data to WriteTransaction, which writes the user data to either csvSAVINGS.TXT or csvCHECKING.TXT 
        activity = New Transaction                          'instance of Transaction 
        calc = New Account                                  'instance of Account 
        activity.TransactionDate = CStr(Today)              'Date of transaction 
        activity.AcctName = cboAccounts.Text                '=Savings or Checking Account chose on form 
        activity.TransactionAmount = CDbl(txtDeposit.Text)  'Amount depositing into Account selected above 
        activity.DepoOrWith = grpDeposit.Text               'Description for writing to file 
        calc.CalcBalance(activity)
        calc.WriteTransaction(activity)                     'WriteTransaction Method in Class Account, writes all user data to selected file.
        txtBalance.Text = FormatCurrency(calc.Balance)
    End Sub
    Private Sub insufficientFunds(ByVal m_balance As Double)

    End Sub
    Private Sub ApprovedFunds()
        MessageBox.Show("Transaction Complete", "Approved")
    End Sub
    Private Sub cboAccounts_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboAccounts.SelectedIndexChanged
        lstTransactions.Items.Clear()
        activity = New Transaction
        Dim nameOfAccount As String = cboAccounts.Text
        Dim listDisplay As ListBox
        If cboAccounts.Text = "Savings" Then
            grpCheck.Visible = False
            activity.AcctName = "Savings"
        Else
            grpCheck.Visible = True
            activity.AcctName = "Checking"
        End If
        listDisplay = lstTransactions
        calc = New Account
        AddHandler calc.approvedTransaction, AddressOf ApprovedFunds
        AddHandler calc.negativeBalance, AddressOf insufficientFunds
        calc.ReadFile(nameOfAccount, listDisplay)
        txtBalance.Text = FormatCurrency(calc.Balance)
    End Sub
End Class 'end Form1

This is the line of code which yields the error when selecting the option 1 or 2 in cboAccount.

 Public ReadOnly Property Balance() As Double
        Get
            Return m_transSet(m_transSet.Length - 1).NewBalance
        End Get
    End Property

It says null reference the value is nothing when in debugger is running

Please any insight would be helpful


If you can help, please do but remember I never took a course in VB so I am a noobie.

Edited 6 Years Ago by __avd: Added [code] tags. Encase your code in: [code] and [/code] tags.

Here you first call the ReadFile method and do a bunch of things.
So far so good.

calc.ReadFile(nameOfAccount, listDisplay)
        txtBalance.Text = FormatCurrency(calc.Balance)

However in the ReadFile method I noticed something.

Sub ReadFile(ByVal NameofAccount As String, ByRef listDisplay As ListBox)
        Dim fmtStr As String = "{0,-10} {1,-30}{2,20:c} {3, 10}"
        Dim tran As Transaction
        Dim x As Integer = 0
        Dim sr As StreamReader = Nothing
        If NameofAccount = "Savings" Then
            sr = File.OpenText("csvSAVINGS.TXT")
        Else 'If NameofAccount = "Checking" Then 
            sr = File.OpenText("csvCHECKING.TXT")
        End If
What happens if sr.Peek actually equals -1?
        Do While (sr.Peek <> -1)
            tran = New Transaction
            fileInput = sr.ReadLine.Split(","c)
            tran.TransactionDate = fileInput(0)
            tran.DepoOrWith = fileInput(1)
            tran.TransactionAmount = fileInput(2)
            tran.PreviousBalance = fileInput(3)
            ReDim Preserve m_transSet(x)
            m_transSet(x) = tran
            listDisplay.Items.Add(String.Format(fmtStr, tran.TransactionDate.ToShortDateString, tran.DepoOrWith, _
            FormatCurrency(tran.TransactionAmount) & " PREV BAL", FormatCurrency(tran.PreviousBalance) & _
            " New BAL" & FormatCurrency(tran.NewBalance)))
            x += 1
            tran = Nothing
        Loop
        sr.Close()
    End Sub

So, if the class variable m_transSet is not set then you will get a null reference error.
Try changing the order of the code so that m_transSet is always not null.

Sub ReadFile(ByVal NameofAccount As String, ByRef listDisplay As ListBox)
        Dim fmtStr As String = "{0,-10} {1,-30}{2,20:c} {3, 10}"
        Dim tran As Transaction
        Dim x As Integer = 0
        Dim sr As StreamReader = Nothing
        If NameofAccount = "Savings" Then
            sr = File.OpenText("csvSAVINGS.TXT")
        Else 'If NameofAccount = "Checking" Then 
            sr = File.OpenText("csvCHECKING.TXT")
        End If
        ReDim m_transSet(x)
        Do While (sr.Peek <> -1)
            tran = New Transaction
            fileInput = sr.ReadLine.Split(","c)
            tran.TransactionDate = fileInput(0)
            tran.DepoOrWith = fileInput(1)
            tran.TransactionAmount = fileInput(2)
            tran.PreviousBalance = fileInput(3)
            m_transSet(x) = tran
            listDisplay.Items.Add(String.Format(fmtStr, tran.TransactionDate.ToShortDateString, tran.DepoOrWith, _
            FormatCurrency(tran.TransactionAmount) & " PREV BAL", FormatCurrency(tran.PreviousBalance) & _
            " New BAL" & FormatCurrency(tran.NewBalance)))
            x += 1
            ReDim Preserve m_transSet(x)
            tran = Nothing
        Loop
        sr.Close()
    End Sub

I am still working on the code you sent, so far no luck. I still receive the same error message. Just can't quite put my finger on it. If I come up with anything new, I will be sure to post it.

Thanks,
puppy

I found some things that you might wanna look at.
If for example the files csvSAVINGS.TXT or csvCHECKING.TXT does not exists then you might wanna change some of the code for the file reading.

In the method CalcBalance, in the Account class, you cannot ReDim m_transSet if the variable x is -1.
When ReDim'ing you have to state the amount of positions in the array to use. Meaning, if the size of the array is supposed to be 1 then the variable x must be declared as 1, not 0 or -1. ReDim variable(<number of positions to declare>) My next suggestion is to check the state of m_transSet in the Balance property:

Public ReadOnly Property Balance() As Double
        Get
            If m_transSet IsNot Nothing Then
               Return m_transSet(m_transSet.Length - 1).NewBalance
            Else
               Return <a default number if all failes>
            End If
        End Get
    End Property

I found some things that you might wanna look at.
If for example the files csvSAVINGS.TXT or csvCHECKING.TXT does not exists then you might wanna change some of the code for the file reading.

In the method CalcBalance, in the Account class, you cannot ReDim m_transSet if the variable x is -1.
When ReDim'ing you have to state the amount of positions in the array to use. Meaning, if the size of the array is supposed to be 1 then the variable x must be declared as 1, not 0 or -1. ReDim variable(<number of positions to declare>) My next suggestion is to check the state of m_transSet in the Balance property:

Public ReadOnly Property Balance() As Double
        Get
            If m_transSet IsNot Nothing Then
               Return m_transSet(m_transSet.Length - 1).NewBalance
            Else
               Return <a default number if all failes>
            End If
        End Get
    End Property

Thanks, your code helped I have completed the deposit and withdrawal buttons, but I am royally stuck on how to get the transfer button to work. It is also returning NULL ref. Do you think it is possible to use the same Public property NewBalance for the transfer to work. I have tried but my attempts fail.
Let me know what you guys think.
PuPpY

Post your code for the transfer button and let's take a look.

For some reason, the deposit and withdrawal buttons have to be clicked twice before calculations are done. And I started the transfer button but I just got lost in all my subs.

Imports System.IO

Public Class form1
    Dim calc As Account
    Dim activity As Transaction
    Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        txtDate.Text = CStr(Today)                          'Displays today's date 
        lblTo.Visible = False
    End Sub

 
    Private Sub btnDeposit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeposit.Click
        'Sends all deposit data to WriteTransaction, which writes the user data to either csvSAVINGS.TXT or csvCHECKING.TXT 
        activity = New Transaction                          'instance of Transaction 
        calc = New Account                                  'instance of Account 
        activity.TransactionDate = CStr(Today)              'Date of transaction 
        activity.AcctName = cboAccounts.Text                '=Savings or Checking Account chose on form 
        activity.TransactionAmount = CDbl(txtDeposit.Text)  'Amount depositing into Account selected above 
        activity.DepoOrWith = grpDeposit.Text               'Description for writing to file 
        calc.CalcBalance(activity)
        calc.WriteTransaction(activity)                     'WriteTransaction Method in Class Account, writes all user data to selected file.
        txtBalance.Text = FormatCurrency(calc.Balance)
    End Sub
    Private Sub btnWithdrawal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWithdrawal.Click
        'Sends all withdrawal data to WriteTransaction, which writes the user data to either csvSAVINGS.TXT or csvCHECKING.TXT 
        activity = New Transaction                          'instance of Transaction 
        calc = New Account                                  'instance of Account 
        activity.TransactionDate = CStr(Today)              'Date of transaction 
        activity.AcctName = cboAccounts.Text                '=Savings or Checking Account chose on form 
        activity.TransactionAmount = CDbl(txtWithdrawal.Text)  'Amount withdrawn from Account selected above 
        activity.DepoOrWith = grpWithdrawal.Text               'Description for writing to file 
        calc.CalcBalance(activity)
        calc.WriteTransaction(activity)                     'WriteTransaction Method in Class Account, writes all user data to selected file.
        txtBalance.Text = FormatCurrency(calc.Balance)
    End Sub
    Private Sub btnTransfer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTransfer.Click
        activity = New Transaction                          'instance of Transaction 
        calc = New Account                                  'instance of Account 
        activity.TransactionDate = CStr(Today)              'Date of transaction 
        activity.AcctName = cboAccounts.Text                '=Savings or Checking Account chose on form 
        activity.TransactionAmount = CDbl(txtTransfer.Text) ' Account to transfer funds from
        activity.DepoOrWith = grpTransfer.Text               'Description for writing to file
        calc.WriteTransaction(activity)                     'WriteTransaction Method in Class Account, writes all user data to selected file.
        txtBalance.Text = FormatCurrency(calc.Balance)
    End Sub
    Private Sub insufficientFunds(ByVal m_balance As Double)

    End Sub
    Private Sub ApprovedFunds()
        MessageBox.Show("Transaction Complete", "Approved")
    End Sub
    Private Sub cboAccounts_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboAccounts.SelectedIndexChanged
        lstTransactions.Items.Clear()
        activity = New Transaction
        Dim nameOfAccount As String = cboAccounts.Text
        Dim listDisplay As ListBox
        If cboAccounts.Text = "Savings" Then
            grpCheck.Visible = False
            activity.AcctName = "Savings"
        Else
            grpCheck.Visible = True
            activity.AcctName = "Checking"
        End If
        listDisplay = lstTransactions
        calc = New Account
        AddHandler calc.approvedTransaction, AddressOf ApprovedFunds
        AddHandler calc.negativeBalance, AddressOf insufficientFunds
        calc.ReadFile(nameOfAccount, listDisplay)
        ' txtBalance.Text = FormatCurrency(calc.Balance)
    End Sub

    
 
    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        'calc.WriteTransaction(activity)                     'WriteTransaction Method in Class Account, writes all user data to selected file.
    End Sub

    Private Sub cboTransfer_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboTransfer.SelectedIndexChanged
        lstTransactions.Items.Clear()
        activity = New Transaction
        Dim nameOfAccount As String = cboTransfer.Text
        'Dim listDisplay As ListBox
        If cboTransfer.Text = "Savings" Then
            'grpCheck.Visible = False
            activity.AcctName = "Savings"
        Else
            grpCheck.Visible = True
            activity.AcctName = "Checking"
        End If
        'listDisplay = lstTransactions
        'calc = New Account
        'AddHandler calc.approvedTransaction, AddressOf ApprovedFunds
        'AddHandler calc.negativeBalance, AddressOf insufficientFunds
        'calc.ReadFile(nameOfAccount, listDisplay)
        'txtBalance.Text = FormatCurrency(calc.Balance)
    End Sub
End Class 'frmAccounts 
Class Transaction
    Private m_prevBal As Double
    Private m_date As Date                                  'Today's date = CStr(Today) 
    Private m_creditDebit As String                         'Deposit or Withdrawal 
    Private m_amount As Double                              'Amount for the transaction 
    Private m_checkOrSave As String                         'Checking or Savings 
    Public Property TransactionDate() As Date               'Date of transaction being made 
        Get
            Return m_date
        End Get
        Set(ByVal value As Date)
            m_date = value
        End Set
    End Property
    Public Property DepoOrWith() As String                  'Deposit or Withdrawal (for both checking and savings)-->DESCRIPTION of transaction 
        Get
            Return m_creditDebit
        End Get
        Set(ByVal value As String)
            m_creditDebit = value
        End Set
    End Property
    Public Property TransactionAmount() As Double           'Amount on transaction attempting to complete 
        Get
            Return m_amount
        End Get
        Set(ByVal value As Double)
            m_amount = value
        End Set
    End Property
    Public Property AcctName() As String                    'Checking or Savings account 
        Get
            Return m_checkOrSave
        End Get
        Set(ByVal value As String)
            m_checkOrSave = value
        End Set
    End Property
    Public Property PreviousBalance() As Double
        Get
            Return m_prevBal
        End Get
        Set(ByVal value As Double)
            m_prevBal = value
        End Set
    End Property
    Public ReadOnly Property NewBalance() As Double
        Get
            If m_creditDebit = "Deposit" Then           'Need to somehow inclued the transfer from and check clearings.
                NewBalance = m_prevBal + m_amount
                'Return NewBalance
            ElseIf m_creditDebit = "WithDrawal" Then
                NewBalance = m_prevBal - m_amount

                Return NewBalance
            End If
        End Get
    End Property
End Class
Class Account
    Private m_Balance As Double                         'Balance for either checking or savings 
    Private m_Savings As Account
    Private m_transSet() As Transaction
    Private m_Checking As Account
    Dim fileInput() As String
    Public Event negativeBalance(ByVal m_balance As Double)
    Public Event approvedTransaction()
    Public Property SavAccount() As Account
        Get
            Return m_Savings
        End Get
        Set(ByVal value As Account)
            m_Savings = value
        End Set
    End Property
    Public Property CheckAccount() As Account
        Get
            Return m_Checking
        End Get
        Set(ByVal value As Account)
            m_Checking = value
        End Set
    End Property
    Public ReadOnly Property Balance() As Double
        Get
            Return m_transSet(m_transSet.Length - 1).NewBalance
        End Get
    End Property
    'Public ReadOnly Property Balance() As Double
    '    Get
    '        If m_transSet IsNot Nothing Then
    '            Return m_transSet(m_transSet.Length - 1).NewBalance
    '        Else
    '            Return 0
    '        End If
    '    End Get
    'End Property
    Public WriteOnly Property transDate() As Date
        Set(ByVal value As Date)
            m_transSet(0).TransactionDate = value
        End Set
    End Property
    Public WriteOnly Property Description() As String
        Set(ByVal value As String)
            m_transSet(1).DepoOrWith = value
        End Set
    End Property
    Public WriteOnly Property Amount() As Double
        Set(ByVal value As Double)
            m_transSet(2).TransactionAmount = value
        End Set
    End Property
    Public WriteOnly Property AccountName() As String
        Set(ByVal value As String)
            m_transSet(3).AcctName = value
        End Set
    End Property

    Sub ReadFile(ByVal NameofAccount As String, ByRef listDisplay As ListBox)
        Dim fmtStr As String = "{0,-10} {1,-30}{2,20:c} {3, 10}"
        Dim tran As Transaction
        Dim x As Integer = 0
        Dim sr As StreamReader = Nothing
        If NameofAccount = "Savings" Then
            sr = File.OpenText("csvSAVINGS.TXT")
        ElseIf NameofAccount = "Checking" Then
            sr = File.OpenText("csvCHECKING.TXT")

        End If
        ReDim m_transSet(x)
        Do While (sr.Peek <> -1)
            tran = New Transaction
            fileInput = sr.ReadLine.Split(","c)
            tran.TransactionDate = fileInput(0)
            tran.DepoOrWith = fileInput(1)
            tran.TransactionAmount = fileInput(2)
            tran.PreviousBalance = fileInput(3)
            m_transSet(x) = tran
            listDisplay.Items.Add(String.Format(fmtStr, tran.TransactionDate.ToShortDateString, tran.DepoOrWith, _
            FormatCurrency(tran.TransactionAmount) & " PREV BAL", FormatCurrency(tran.PreviousBalance) & _
            " New BAL" & FormatCurrency(tran.NewBalance)))
            x += 1
            ReDim Preserve m_transSet(x)
            tran = Nothing
        Loop
        sr.Close()
    End Sub

    Function CalcBalance(ByVal activity As Transaction) As Double
        Dim tran As Transaction
        Dim x As Integer = -1
        Dim sr As StreamReader = Nothing
        If activity.AcctName = "Savings" Then
            sr = File.OpenText("csvSavings.TXT")
        ElseIf activity.AcctName = "Checking" Then
            sr = File.OpenText("csvChecking.TXT")
        End If
        Do While (sr.Peek <> -1)
            tran = New Transaction
            fileInput = sr.ReadLine.Split(","c)
            tran.TransactionDate = fileInput(0)
            tran.DepoOrWith = fileInput(1)
            tran.TransactionAmount = fileInput(2)
            tran.PreviousBalance = fileInput(3)
            x += 1
            ReDim Preserve m_transSet(x)
            m_transSet(x) = tran
            tran = Nothing
        Loop
        sr.Close()
        If Balance <= 0 Then
                RaiseEvent negativeBalance(Balance)
        Else
                RaiseEvent approvedTransaction()
            End If
            Return Balance
    End Function
    Sub WriteTransaction(ByVal activity As Transaction)
        CalcBalance(activity)
        Dim temp() As String = {activity.TransactionDate & "," & activity.DepoOrWith.ToString & "," & _
        activity.TransactionAmount & "," & Balance}
        Select Case activity.AcctName
            Case Is = "Savings"
                Dim sw As StreamWriter = File.AppendText("csvSAVINGS.TXT")
                sw.WriteLine(Join(temp, ","))
                sw.Close()
            Case Is = "Checking"
                Dim sw As StreamWriter = File.AppendText("csvCHECKING.TXT")
                sw.WriteLine(Join(temp, ","))
                RaiseEvent approvedTransaction()
                sw.Close()
            Case Is = "Transfer to Checking"
                Dim sw1 As StreamWriter = File.AppendText("csvCHECKING.TXT")
                Dim sw2 As StreamWriter = File.AppendText("csvSAVINGS.TXT")
                Dim temp2() As String = {activity.TransactionDate & "," & activity.AcctName & "," & activity.TransactionAmount}
                sw1.WriteLine(Join(temp, ","))
                sw2.WriteLine(Join(temp2, ","))
                sw1.Close()
                sw2.Close()
            Case Is = "Transfer to Savings"
                Dim sw1 As StreamWriter = File.AppendText("csvSAVINGS.TXT")
                Dim sw2 As StreamWriter = File.AppendText("csvCHECKING.TXT")
                Dim temp2() As String = {activity.TransactionDate & "," & activity.AcctName & "," & activity.TransactionAmount}
                sw1.WriteLine(Join(temp, ","))
                sw2.WriteLine(Join(temp2, ","))
                sw1.Close()
                sw2.Close()
        End Select
    End Sub
End Class

Well. I couldn't really see anything wrong with your logic.
However, what can you see when you debug your transaction code and step through each line to see what line creates the NULL reference?
Just put a breakpoint at Private Sub btnTransfer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTransfer.Click and follow the code.

I know it's unrelated but the first thing I did notice was this.

Sub WriteTransaction(ByVal activity As Transaction)
        CalcBalance(activity)
'This is only a single item array. And nothing really won't be accomplished with the Join method.
        Dim temp() As String = {activity.TransactionDate & "," & activity.DepoOrWith.ToString & "," & _
        activity.TransactionAmount & "," & Balance}
'Try the code in red instead
        Dim temp As String = activity.TransactionDate & "," & activity.DepoOrWith.ToString & "," & _
        activity.TransactionAmount & "," & Balance
        Select Case activity.AcctName
            Case Is = "Savings"
                Dim sw As StreamWriter = File.AppendText("csvSAVINGS.TXT")
                sw.WriteLine(temp)
                sw.Flush()
                sw.Close()
            .....
        End Select
    End Sub

Well. I couldn't really see anything wrong with your logic.
However, what can you see when you debug your transaction code and step through each line to see what line creates the NULL reference?
Just put a breakpoint at Private Sub btnTransfer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTransfer.Click and follow the code.

I know it's unrelated but the first thing I did notice was this.

Sub WriteTransaction(ByVal activity As Transaction)
        CalcBalance(activity)
'This is only a single item array. And nothing really won't be accomplished with the Join method.
        Dim temp() As String = {activity.TransactionDate & "," & activity.DepoOrWith.ToString & "," & _
        activity.TransactionAmount & "," & Balance}
'Try the code in red instead
        Dim temp As String = activity.TransactionDate & "," & activity.DepoOrWith.ToString & "," & _
        activity.TransactionAmount & "," & Balance
        Select Case activity.AcctName
            Case Is = "Savings"
                Dim sw As StreamWriter = File.AppendText("csvSAVINGS.TXT")
                sw.WriteLine(temp)
                sw.Flush()
                sw.Close()
            .....
        End Select
    End Sub

I just looked at the code and decided to use a different approach. I will probably mark this as solved and start a new post because I solved the class errors. It is now a matter of the redim preserve statement. At any rate, here is the code.

Public Class Form1
    'load contents of Text file into the listbox when first loaded
    'store data in file into array of accounts, record no. counts
    WithEvents acc1 As New Account
    Dim ac(0) As Account
    Dim count As Integer = 0
    Dim curDateTime As String = CStr(Now)
    Dim cBal As Double, sBal As Double 'stores the latest balances from both accounts
    Dim flag As Boolean = False 'changes to true if "check if balance is below 0"

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        acc1 = New Account
        'acc1.fileControl("Open", ac, acc1, count)
        'grpAccount.Enabled = False
        ' grpCheck.Enabled = False
        'grpDeposit.Enabled = False
        'grpTransactions.Enabled = False
        ' btnSave.Enabled = False
        lblTo.Text = "to N/A"
        txtDate.Text = CStr(Now.Date)
    End Sub
    Private Sub CboAccounts_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboAccounts.SelectedIndexChanged
        lstTransactions.Items.Clear()
        acc1 = New Account
        Select Case cboAccounts.SelectedItem
            Case Is = "Savings"
                grpAccount.Enabled = True
                grpDeposit.Enabled = True
                grpTransactions.Enabled = True
                grpWithdrawal.Enabled = False
                btnSave.Enabled = True
            Case Is = "Checking"
                grpAccount.Enabled = True
                grpCheck.Enabled = True
                grpDeposit.Enabled = True
                grpWithdrawal.Enabled = True
                btnSave.Enabled = True
        End Select
        'finds, displays new balances and shows transactions in listbox.
        reDisplay(lstTransactions, cboAccounts.SelectedItem)
    End Sub
    'Finds and Display the current balances in both accounts
    Private Sub currBal(ByVal type1 As String)

        Dim flagA As Boolean = False, flagB As Boolean = False
        'gets and sets the current balance for the savings and checking accounts
        For i As Integer = ac.GetUpperBound(0) To 0 Step -1
            If ac(i) IsNot Nothing Then
                If ac(i).Type = "Savings" And flagA = False Then
                    sBal = ac(i).SaveBalance : flagA = True
                End If
                If ac(i).Type = "Checking" And flagB = False Then
                    cBal = ac(i).CheckBalance : flagB = True
                End If
                If flagA = True And flagB = True Then
                    Exit For
                End If
            End If
        Next
        txtBalance.TextAlign = HorizontalAlignment.Center
        If type1 = "Savings" Then
            txtBalance.Text = FormatCurrency(sBal, 2)
        Else
            txtBalance.Text = FormatCurrency(cBal, 2)
        End If
    End Sub
    
    'Handles the Deposit Groupbox
    Private Sub BtnDeposit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeposit.Click
        flag = False
        acc1 = New Account
        acc1.DateNow = curDateTime.Substring(0, curDateTime.IndexOf(" "))
        acc1.Name = "Deposit"
        acc1.Ammount = CDbl(txtDeposit.Text)
        acc1.Type = cboAccounts.SelectedItem
        If cboAccounts.SelectedItem = "Savings" Then
            acc1.calcSav("Deposit", acc1.Ammount, sBal)
            If flag = False Then
                ReDim Preserve ac(ac.GetUpperBound(0) + 1)
                ac(count) = acc1
                count += 1
            End If
        Else
            acc1.calcCheck("Deposit", acc1.Ammount, cBal)
            If flag = False Then
                ReDim Preserve ac(ac.GetUpperBound(0) + 1)
                ac(count) = acc1
                count += 1
            End If
        End If
        reDisplay(lstTransactions, cboAccounts.SelectedItem)
    End Sub
    'Handles the Withdrawal Groupbox
    Private Sub BtnWithdrawal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWithdrawal.Click
        flag = False
        acc1 = New Account
        acc1.DateNow = curDateTime.Substring(0, curDateTime.IndexOf(" "))
        acc1.Name = "Withdrawal"
        acc1.Ammount = CDbl(txtWithdrawal.Text)
        acc1.Type = cboAccounts.SelectedItem
        If cboAccounts.SelectedItem = "Savings" Then
            acc1.calcSav("Withdrawal", acc1.Ammount, sBal)
            If flag = False Then
                ReDim Preserve ac(ac.GetUpperBound(0) + 1)
                ac(count) = acc1
                count += 1
            End If
        Else
            acc1.calcCheck("Withdrawal", acc1.Ammount, cBal)
            If flag = False Then
                ReDim Preserve ac(ac.GetUpperBound(0) + 1)
                ac(count) = acc1
                count += 1
            End If
        End If
        reDisplay(lstTransactions, cboAccounts.SelectedItem)
    End Sub
    Private Sub CboTransfer_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboTransfer.SelectedIndexChanged
        'switches the transfer label depending on combobox choice
        If cboTransfer.SelectedItem = "Savings" Then
            lblTo.Text = "to Checking"
        ElseIf cboTransfer.SelectedItem = "Checking" Then
            lblTo.Text = "to Savings"
        End If
    End Sub
    'Handles the Transfer Groupbox
    Private Sub BtnTransfer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTransfer.Click
        flag = False
        acc1 = New Account
        acc1.Ammount = CDbl(txtTransfer.Text)
        acc1.Type = cboAccounts.SelectedItem
        acc1.DateNow = curDateTime.Substring(0, curDateTime.IndexOf(" "))
        currBal(cboAccounts.SelectedItem)

        'the following code is used if using the savings account
        If cboAccounts.SelectedItem = "Savings" Then
            acc1.calcTrans(cboTransfer.SelectedItem, acc1.Ammount, cBal, sBal)
            If cboTransfer.SelectedItem = "Savings" Then
                acc1.Name = "Transfer to Checking"
            ElseIf cboTransfer.SelectedItem = "Checking" Then
                acc1.Name = "Transfer from Checking"
            End If
            If flag = False Then
                ReDim Preserve ac(ac.GetUpperBound(0) + 1)
                Dim bal = acc1.CheckBalance
                ac(count) = acc1
                count += 1
                ReDim Preserve ac(ac.GetUpperBound(0) + 1)
                acc1 = New Account
                acc1.CheckBalance = bal
                acc1.DateNow = curDateTime.Substring(0, curDateTime.IndexOf(" "))
                acc1.Ammount = CDbl(txtTransfer.Text)
                acc1.Type = "Checking"
                If cboTransfer.SelectedItem = "Savings" Then
                    acc1.Name = "Transfer from Savings"
                Else
                    acc1.Name = "Transfer to Savings"
                End If
                ac(count) = acc1
                count += 1
            End If
        Else
            'the following code is used if using the checking account
            acc1.calcTrans(cboTransfer.SelectedItem, acc1.Ammount, cBal, sBal)
            If cboTransfer.SelectedItem = "Savings" Then
                acc1.Name = "Transfer from Savings"
            ElseIf cboTransfer.SelectedItem = "Checking" Then
                acc1.Name = "Transfer to Savings"
            End If
            If flag = False Then
                ReDim Preserve ac(ac.GetUpperBound(0) + 1)
                Dim bal = acc1.SaveBalance
                ac(count) = acc1
                count += 1
                ReDim Preserve ac(ac.GetUpperBound(0) + 1)
                acc1 = New Account
                acc1.SaveBalance = bal
                acc1.DateNow = curDateTime.Substring(0, curDateTime.IndexOf(" "))
                acc1.Ammount = CDbl(txtTransfer.Text)
                acc1.Type = "Savings"
                If cboTransfer.SelectedItem = "Savings" Then
                    acc1.Name = "Transfer to Checking"
                Else
                    acc1.Name = "Transfer from Checking"
                End If
                ac(count) = acc1
                count += 1
            End If
        End If
        reDisplay(lstTransactions, cboAccounts.SelectedItem)
    End Sub
    'Handles the Checking Check Groupbox
    Private Sub BtnCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheck.Click
        flag = False
        acc1 = New Account
        acc1.DateNow = curDateTime.Substring(0, curDateTime.IndexOf(" "))
        acc1.Ammount = CDbl(txtCheck.Text)
        acc1.Name = "Check cashed by " & CStr(txtPayee.Text)
        acc1.Type = "Checking"
        acc1.calcCheck("Check", acc1.Ammount, cBal)
        If flag = False Then
            ReDim Preserve ac(ac.GetUpperBound(0) + 1)
            ac(count) = acc1
            count += 1
        End If
        reDisplay(lstTransactions, cboAccounts.SelectedItem)
    End Sub
    'triggered when user inputs name into check
    Private Sub TxtPayee_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPayee.Click
        MessageBox.Show("Please only input Company Name")
    End Sub
    'triggered when not funds are available
    Private Sub Funds_Check() Handles acc1.FundsError
        MessageBox.Show("Funds Not Available for transaction")
        flag = True
    End Sub
    'finds, displays new balances and shows transactions in listbox.
    Private Sub reDisplay(ByVal lB As ListBox, ByVal type As String)
        currBal(type)
        acc1.Trans = ac
        acc1.popList(lstTransactions, type)
        flag = False
    End Sub
    Class Transaction
        Private t_name As String
        Private t_ammount As Double
        Private t_date As String
        Private t_type As String

        Public Property Name()
            Get
                Return t_name
            End Get
            Set(ByVal value)
                t_name = value
            End Set
        End Property

        Public Property Ammount()
            Get
                Return t_ammount
            End Get
            Set(ByVal value)
                t_ammount = value
            End Set
        End Property

        Public Property DateNow()
            Get
                Return t_date
            End Get
            Set(ByVal value)
                t_date = value
            End Set
        End Property

        Public Property Type()
            Get
                Return t_type
            End Get
            Set(ByVal value)
                t_type = value
            End Set
        End Property
    End Class

    Class Account
        Inherits Transaction
        Private a_Trans() As Account
        Private a_Trans1() As Account
        Private a_Count As Double = 0
        Private a_savBalance As Double
        Private a_checkBalance As Double
        Public Event FundsError()
        Public Event TransSuccess(ByVal type As String)
        Public Property Trans()
            Get
                Return a_Trans(a_Count)
            End Get
            Set(ByVal value)
                a_Trans = value
            End Set
        End Property
        Public Property Trans1()
            Get
                Return a_Trans1(a_Count)
            End Get
            Set(ByVal value)
                a_Trans1 = value
            End Set
        End Property

        Public Property Count()
            Get
                Return a_Count
            End Get
            Set(ByVal value)
                a_Count = value
            End Set
        End Property

        Public Property SaveBalance()
            Get
                Return a_savBalance
            End Get
            Set(ByVal value)
                a_savBalance = value
            End Set
        End Property
        Public Property CheckBalance()
            Get
                Return a_checkBalance
            End Get
            Set(ByVal value)
                a_checkBalance = value
            End Set
        End Property

        'Handles Saving Account calculations - Deposit/Withdrawal 
        Sub calcSav(ByVal Type1 As String, ByVal ammount As Double, ByVal bal As Double)
            Select Case Type1
                Case Is = "Deposit"
                    a_savBalance = bal + ammount
                    RaiseEvent TransSuccess("Deposit")


                Case Is = "Withdrawal"
                    If bal <= 0 Or ((bal - ammount) < 0) Then
                        RaiseEvent FundsError()
                        Exit Sub
                    Else
                        a_savBalance = bal - ammount
                        RaiseEvent TransSuccess("Withdrawal")
                    End If
            End Select
        End Sub
        'Handles Checking Account calculations - Deposit/Withdrawal/Checks
        Sub calcCheck(ByVal Type1 As String, ByVal ammount As Double, ByVal bal As Double)
            Select Case Type1
                Case Is = "Deposit"
                    a_checkBalance = bal + ammount
                    RaiseEvent TransSuccess("Deposit")


                Case Is = "Withdrawal"
                    If bal <= 0 Or ((bal - ammount) < 0) Then
                        RaiseEvent FundsError()
                        Exit Sub
                    Else
                        a_checkBalance = bal - ammount
                        RaiseEvent TransSuccess("Withdrawal")
                    End If

                Case Is = "Transfer"
                    If bal <= 0 Or ((bal - ammount) < 0) Then
                        RaiseEvent FundsError()
                        Exit Sub
                    Else
                        a_checkBalance = bal - ammount
                        RaiseEvent TransSuccess("Transfer")
                    End If

                Case Is = "Check"
                    If bal <= 0 Or (bal - ammount < 0) Then
                        RaiseEvent FundsError()
                        Exit Sub
                    Else
                        a_checkBalance = bal - ammount
                        RaiseEvent TransSuccess("Check")
                    End If
            End Select
        End Sub

        'Handles the transfer groupbox calculations
        Sub calcTrans(ByVal Type As String, ByVal amm As Double, ByVal cBal As Double, ByVal sBal As Double)
            If Type = "Savings" Then
                If sBal < 0 Or (sBal - amm) < 0 Then
                    RaiseEvent FundsError()
                    Exit Sub
                Else
                    a_savBalance = sBal - amm
                    a_checkBalance = cBal + amm
                End If
            Else
                If cBal < 0 Or (cBal - amm) < 0 Then
                    RaiseEvent FundsError()
                    Exit Sub
                Else
                    a_checkBalance = cBal - amm
                    a_savBalance = sBal + amm
                End If
            End If
        End Sub

        Sub popList(ByRef lb As ListBox, ByVal type As String)
            lb.Items.Clear()
            For i As Integer = 0 To a_Trans.GetUpperBound(0)
                If a_Trans(i) IsNot Nothing Then
                    If type = "Savings" And a_Trans(i).Type = "Savings" Then
                        If a_Trans(i).Name = "Deposit" Or a_Trans(i).Name = "Transfer from Checking" Or a_Trans(i).Name = "Transfer from Savings" Then
                            lb.Items.Add(a_Trans(i).DateNow & _
                                         "  " & a_Trans(i).Name & _
                                         "         AMOUNT->   " & FormatCurrency(a_Trans(i).Ammount, 2) & _
                                         "         PREV BAL->  " & FormatCurrency((a_Trans(i).SaveBalance - a_Trans(i).Ammount), 2) & _
                                         "         NEW BAL->   " & FormatCurrency(a_Trans(i).SaveBalance, 2))
                            ' There is a problem here
                        ElseIf a_Trans(i).Name = "Withdrawal" Or a_Trans(i).Name = "Transfer to Checking" Or a_Trans(i).Name = "Transfer to Savings" Or a_Trans(i).Name.substring(0, 6) = "Check " Then
                            lb.Items.Add(a_Trans(i).DateNow & _
                                         "  " & a_Trans(i).Name & _
                                         "         AMOUNT->   " & FormatCurrency(a_Trans(i).Ammount, 2) & _
                                         "         PREV BAL->  " & FormatCurrency((a_Trans(i).SaveBalance + a_Trans(i).Ammount), 2) & _
                                         "         NEW BAL->   " & FormatCurrency(a_Trans(i).SaveBalance, 2))
                        End If
                    ElseIf type = "Checking" And a_Trans(i).Type = "Checking" Then
                        If a_Trans(i).Name = "Deposit" Or a_Trans(i).Name = "Transfer from Checking" Or a_Trans(i).Name = "Transfer from Savings" Then
                            lb.Items.Add(a_Trans(i).DateNow & _
                                         "  " & a_Trans(i).Name & _
                                         "         AMOUNT->   " & FormatCurrency(a_Trans(i).Ammount, 2) & _
                                         "         PREV BAL->  " & FormatCurrency((a_Trans(i).CheckBalance - a_Trans(i).Ammount), 2) & _
                                         "         NEW BAL->   " & FormatCurrency(a_Trans(i).CheckBalance, 2))
                        ElseIf a_Trans(i).Name = "Withdrawal" Or a_Trans(i).Name = "Transfer to Checking" Or a_Trans(i).Name = "Transfer to Savings" Or a_Trans(i).Name.substring(0, 6) = "Check " Then
                            lb.Items.Add(a_Trans(i).DateNow & _
                                         "  " & a_Trans(i).Name & _
                                         "         AMOUNT->   " & FormatCurrency(a_Trans(i).Ammount, 2) & _
                                         "         PREV BAL->  " & FormatCurrency((a_Trans(i).CheckBalance + a_Trans(i).Ammount), 2) & _
                                         "         NEW BAL->   " & FormatCurrency(a_Trans(i).CheckBalance, 2))
                        End If
                    End If
                End If
            Next
        End Sub

        Sub SaveFile(ByVal func As String, ByVal ac As Array, ByRef acc1 As Account, ByRef count As Double)

            Dim sa As IO.StreamReader = IO.File.OpenText("D:\Documents and Settings\My Documents\VB-Textfiles\Object\ACCOUNTS.txt")
            Dim sr As IO.StreamWriter = IO.File.CreateText("TEMP.TXT")
            If func = "Open" Then
                Do While sa.Peek <> -1
                    acc1 = New Account
                    Dim a = sa.ReadLine
                    If a = Nothing Then
                        Exit Do
                    Else
                        Dim line() = a.Split(","c)
                        acc1.DateNow = line(0)
                        acc1.Name = line(1)
                        acc1.Ammount = line(2)
                        acc1.Type = line(4)
                        If line(4) = "Checking" Then
                            acc1.CheckBalance = line(3)
                        Else
                            acc1.SaveBalance = line(3)
                        End If
                    End If

                    '*****************************************************************************

                    ' *The problem is here says that the redim preserve wont work. Why?.

                    ac(count) = acc1
                    ' x = ac.GetUpperBound + 1
                    ' ReDim Preserve ac(ac.GetUpperBound(0) + 1)



                    '***************************************************************************

                    count += 1
                Loop
                sa.Close()
                sr.Close()
            Else
            End If
        End Sub
    End Class
    ''Handles the File storing of all transactions
    'Private Sub BtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click

    'End Sub

End Class

Thanks for the help, If you notice I placed comments where I am returning errors, and I have yet to plug the save sub into the save button because it won't let me call the sub..

Instead of using GetUpperBound, try using Length.
See code in red.

Sub SaveFile(ByVal func As String, ByVal ac As Array, ByRef acc1 As Account, ByRef count As Double)

            Dim sa As IO.StreamReader = IO.File.OpenText("D:\Documents and Settings\My Documents\VB-Textfiles\Object\ACCOUNTS.txt")
            Dim sr As IO.StreamWriter = IO.File.CreateText("TEMP.TXT")
            If func = "Open" Then
                Do While sa.Peek <> -1
                    acc1 = New Account
                    Dim a = sa.ReadLine
                    If a = Nothing Then
                        Exit Do
                    Else
                        Dim line() = a.Split(","c)
                        acc1.DateNow = line(0)
                        acc1.Name = line(1)
                        acc1.Ammount = line(2)
                        acc1.Type = line(4)
                        If line(4) = "Checking" Then
                            acc1.CheckBalance = line(3)
                        Else
                            acc1.SaveBalance = line(3)
                        End If
                    End If

                    '*****************************************************************************

                    ' *The problem is here says that the redim preserve wont work. Why?.

                    ac(count) = acc1
                    ' x = ac.GetUpperBound + 1
                    ' ReDim Preserve ac(ac.Length + 1)



                    '***************************************************************************

                    count += 1
                Loop
                sa.Close()
                sr.Close()
            Else
            End If
        End Sub
    End Class
    ''Handles the File storing of all transactions
    'Private Sub BtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click

    'End Sub

End Class

Thanks for the help, If you notice I placed comments where I am returning errors, and I have yet to plug the save sub into the save button because it won't let me call the sub..

Have you tried declaring the SaveFile method as Public?
Just like properties, methods needs to be Public in order to be accessible from outside the class.

Instead of using GetUpperBound, try using Length.
See code in red.

Sub SaveFile(ByVal func As String, ByVal ac As Array, ByRef acc1 As Account, ByRef count As Double)

            Dim sa As IO.StreamReader = IO.File.OpenText("D:\Documents and Settings\My Documents\VB-Textfiles\Object\ACCOUNTS.txt")
            Dim sr As IO.StreamWriter = IO.File.CreateText("TEMP.TXT")
            If func = "Open" Then
                Do While sa.Peek <> -1
                    acc1 = New Account
                    Dim a = sa.ReadLine
                    If a = Nothing Then
                        Exit Do
                    Else
                        Dim line() = a.Split(","c)
                        acc1.DateNow = line(0)
                        acc1.Name = line(1)
                        acc1.Ammount = line(2)
                        acc1.Type = line(4)
                        If line(4) = "Checking" Then
                            acc1.CheckBalance = line(3)
                        Else
                            acc1.SaveBalance = line(3)
                        End If
                    End If

                    '*****************************************************************************

                    ' *The problem is here says that the redim preserve wont work. Why?.

                    ac(count) = acc1
                    ' x = ac.GetUpperBound + 1
                    ' ReDim Preserve ac(ac.Length + 1)



                    '***************************************************************************

                    count += 1
                Loop
                sa.Close()
                sr.Close()
            Else
            End If
        End Sub
    End Class
    ''Handles the File storing of all transactions
    'Private Sub BtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click

    'End Sub

End Class

Have you tried declaring the SaveFile method as Public?
Just like properties, methods needs to be Public in order to be accessible from outside the class.

Imports System.IO
Public Class Form1
    'load contents of Text file into the listbox when first loaded
    'store data in file into array of accounts, record no. counts
    WithEvents acc1 As New Account
    Dim ac(0) As Account
    Dim count As Integer = 0
    Dim curDateTime As String = CStr(Now)
    Dim cBal As Double, sBal As Double 'stores the latest balances from both accounts
    Dim flag As Boolean = False 'changes to true if "check if balance is below 0"

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        acc1 = New Account
        ' acc1.SaveFile("Open", ac, acc1, count)
        grpAccount.Enabled = True
        grpCheck.Enabled = False
        grpDeposit.Enabled = False
        grpTransactions.Enabled = False
        btnSave.Enabled = False
        lblTo.Text = "to N/A"
        txtDate.Text = CStr(Now.Date)
    End Sub
    Private Sub CboAccounts_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboAccounts.SelectedIndexChanged
        lstTransactions.Items.Clear()
        acc1 = New Account
        Select Case cboAccounts.SelectedItem
            Case Is = "Savings"
                grpAccount.Enabled = True
                grpDeposit.Enabled = True
                grpTransactions.Enabled = True
                grpWithdrawal.Enabled = False
                btnSave.Enabled = True
            Case Is = "Checking"
                grpAccount.Enabled = True
                grpCheck.Enabled = True
                grpDeposit.Enabled = True
                grpWithdrawal.Enabled = True
                btnSave.Enabled = True
        End Select
        'finds, displays new balances and shows transactions in listbox.
        reDisplay(lstTransactions, cboAccounts.SelectedItem)
    End Sub
    'Finds and Display the current balances in both accounts
    Private Sub currBal(ByVal type1 As String)

        Dim flagA As Boolean = False, flagB As Boolean = False
        'gets and sets the current balance for the savings and checking accounts
        For i As Integer = ac.GetUpperBound(0) To 0 Step -1
            If ac(i) IsNot Nothing Then
                If ac(i).Type = "Savings" And flagA = False Then
                    sBal = ac(i).SaveBalance : flagA = True
                End If
                If ac(i).Type = "Checking" And flagB = False Then
                    cBal = ac(i).CheckBalance : flagB = True
                End If
                If flagA = True And flagB = True Then
                    Exit For
                End If
            End If
        Next
        txtBalance.TextAlign = HorizontalAlignment.Center
        If type1 = "Savings" Then
            txtBalance.Text = FormatCurrency(sBal, 2)
        Else
            txtBalance.Text = FormatCurrency(cBal, 2)
        End If
    End Sub

    'Handles the Deposit Groupbox
    Private Sub BtnDeposit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeposit.Click
        flag = False
        acc1 = New Account
        acc1.DateNow = curDateTime.Substring(0, curDateTime.IndexOf(" "))
        acc1.Name = "Deposit"
        acc1.Amount = CDbl(txtDeposit.Text)
        acc1.Type = cboAccounts.SelectedItem
        If cboAccounts.SelectedItem = "Savings" Then
            acc1.calcSav("Deposit", acc1.Amount, sBal)
            If flag = False Then
                ReDim Preserve ac(ac.GetUpperBound(0) + 1)
                ac(count) = acc1
                count += 1
            End If
        Else
            acc1.calcCheck("Deposit", acc1.Amount, cBal)
            If flag = False Then
                ReDim Preserve ac(ac.GetUpperBound(0) + 1)
                ac(count) = acc1
                count += 1
            End If
        End If
        reDisplay(lstTransactions, cboAccounts.SelectedItem)
    End Sub
    'Handles the Withdrawal Groupbox
    Private Sub BtnWithdrawal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWithdrawal.Click
        flag = False
        acc1 = New Account
        acc1.DateNow = curDateTime.Substring(0, curDateTime.IndexOf(" "))
        acc1.Name = "Withdrawal"
        acc1.Amount = CDbl(txtWithdrawal.Text)
        acc1.Type = cboAccounts.SelectedItem
        If cboAccounts.SelectedItem = "Savings" Then
            acc1.calcSav("Withdrawal", acc1.Amount, sBal)
            If flag = False Then
                ReDim Preserve ac(ac.GetUpperBound(0) + 1)
                ac(count) = acc1
                count += 1
            End If
        Else
            acc1.calcCheck("Withdrawal", acc1.Amount, cBal)
            If flag = False Then
                ReDim Preserve ac(ac.GetUpperBound(0) + 1)
                ac(count) = acc1
                count += 1
            End If
        End If
        reDisplay(lstTransactions, cboAccounts.SelectedItem)
    End Sub
    Private Sub CboTransfer_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboTransfer.SelectedIndexChanged
        'switches the transfer label depending on combobox choice
        If cboTransfer.SelectedItem = "Savings" Then
            lblTo.Text = "to Checking"
        ElseIf cboTransfer.SelectedItem = "Checking" Then
            lblTo.Text = "to Savings"
        End If
    End Sub
    'Handles the Transfer Groupbox
    Private Sub BtnTransfer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTransfer.Click
        flag = False
        acc1 = New Account
        acc1.Amount = CDbl(txtTransfer.Text)
        acc1.Type = cboAccounts.SelectedItem
        acc1.DateNow = curDateTime.Substring(0, curDateTime.IndexOf(" "))
        currBal(cboAccounts.SelectedItem)

        'the following code is used if using the savings account
        If cboAccounts.SelectedItem = "Savings" Then
            acc1.calcTrans(cboTransfer.SelectedItem, acc1.Amount, cBal, sBal)
            If cboTransfer.SelectedItem = "Savings" Then
                acc1.Name = "Transfer to Checking"
            ElseIf cboTransfer.SelectedItem = "Checking" Then
                acc1.Name = "Transfer from Checking"
            End If
            If flag = False Then
                ReDim Preserve ac(ac.GetUpperBound(0) + 1)
                Dim bal = acc1.CheckBalance
                ac(count) = acc1
                count += 1
                ReDim Preserve ac(ac.GetUpperBound(0) + 1)
                acc1 = New Account
                acc1.CheckBalance = bal
                acc1.DateNow = curDateTime.Substring(0, curDateTime.IndexOf(" "))
                acc1.Amount = CDbl(txtTransfer.Text)
                acc1.Type = "Checking"
                If cboTransfer.SelectedItem = "Savings" Then
                    acc1.Name = "Transfer from Savings"
                Else
                    acc1.Name = "Transfer to Savings"
                End If
                ac(count) = acc1
                count += 1
            End If
        Else
            'the following code is used if using the checking account
            acc1.calcTrans(cboTransfer.SelectedItem, acc1.Amount, cBal, sBal)
            If cboTransfer.SelectedItem = "Savings" Then
                acc1.Name = "Transfer from Savings"
            ElseIf cboTransfer.SelectedItem = "Checking" Then
                acc1.Name = "Transfer to Savings"
            End If
            If flag = False Then
                ReDim Preserve ac(ac.GetUpperBound(0) + 1)
                Dim bal = acc1.SaveBalance
                ac(count) = acc1
                count += 1
                ReDim Preserve ac(ac.GetUpperBound(0) + 1)
                acc1 = New Account
                acc1.SaveBalance = bal
                acc1.DateNow = curDateTime.Substring(0, curDateTime.IndexOf(" "))
                acc1.Amount = CDbl(txtTransfer.Text)
                acc1.Type = "Savings"
                If cboTransfer.SelectedItem = "Savings" Then
                    acc1.Name = "Transfer to Checking"
                Else
                    acc1.Name = "Transfer from Checking"
                End If
                ac(count) = acc1
                count += 1
            End If
        End If
        reDisplay(lstTransactions, cboAccounts.SelectedItem)
    End Sub
    'Handles the Checking Check Groupbox
    Private Sub BtnCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheck.Click
        flag = False
        acc1 = New Account
        acc1.DateNow = curDateTime.Substring(0, curDateTime.IndexOf(" "))
        acc1.Amount = CDbl(txtCheck.Text)
        acc1.Name = "Check cashed by " & CStr(txtPayee.Text)
        acc1.Type = "Checking"
        acc1.calcCheck("Check", acc1.Amount, cBal)
        If flag = False Then
            ReDim Preserve ac(ac.GetUpperBound(0) + 1)
            ac(count) = acc1
            count += 1
        End If
        reDisplay(lstTransactions, cboAccounts.SelectedItem)
    End Sub
    'triggered when user inputs name into check
    Private Sub TxtPayee_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPayee.Click
        MessageBox.Show("Please only input Company Name")
    End Sub
    'triggered when not funds are available
    Private Sub Funds_Check() Handles acc1.FundsError
        MessageBox.Show("Funds Not Available for transaction")
        flag = True
    End Sub
    'finds, displays new balances and shows transactions in listbox.
    Private Sub reDisplay(ByVal lB As ListBox, ByVal type As String)
        currBal(type)
        acc1.Trans = ac
        acc1.popList(lstTransactions, type)
        flag = False
    End Sub
    Class Transaction
        Private t_name As String
        Private t_amount As Double
        Private t_date As String
        Private t_type As String

        Public Property Name()
            Get
                Return t_name
            End Get
            Set(ByVal value)
                t_name = value
            End Set
        End Property

        Public Property Amount()
            Get
                Return t_amount
            End Get
            Set(ByVal value)
                t_amount = value
            End Set
        End Property

        Public Property DateNow()
            Get
                Return t_date
            End Get
            Set(ByVal value)
                t_date = value
            End Set
        End Property

        Public Property Type()
            Get
                Return t_type
            End Get
            Set(ByVal value)
                t_type = value
            End Set
        End Property
    End Class

    Class Account
        Inherits Transaction
        Private a_Trans() As Account
        Private a_Trans1() As Account
        Private a_Count As Double = 0
        Private a_savBalance As Double
        Private a_checkBalance As Double
        Public Event FundsError()
        Public Event TransSuccess(ByVal type As String)
        Public Property Trans()
            Get
                Return a_Trans(a_Count)
            End Get
            Set(ByVal value)
                a_Trans = value
            End Set
        End Property
        Public Property Trans1()
            Get
                Return a_Trans1(a_Count)
            End Get
            Set(ByVal value)
                a_Trans1 = value
            End Set
        End Property

        Public Property Count()
            Get
                Return a_Count
            End Get
            Set(ByVal value)
                a_Count = value
            End Set
        End Property

        Public Property SaveBalance()
            Get
                Return a_savBalance
            End Get
            Set(ByVal value)
                a_savBalance = value
            End Set
        End Property
        Public Property CheckBalance()
            Get
                Return a_checkBalance
            End Get
            Set(ByVal value)
                a_checkBalance = value
            End Set
        End Property

        'Handles Saving Account calculations - Deposit/Withdrawal 
        Sub calcSav(ByVal Type1 As String, ByVal amount As Double, ByVal bal As Double)
            Select Case Type1
                Case Is = "Deposit"
                    a_savBalance = bal + amount
                    RaiseEvent TransSuccess("Deposit")


                Case Is = "Withdrawal"
                    If bal <= 0 Or ((bal - amount) < 0) Then
                        RaiseEvent FundsError()
                        Exit Sub
                    Else
                        a_savBalance = bal - amount
                        RaiseEvent TransSuccess("Withdrawal")
                    End If
            End Select
        End Sub
        'Handles Checking Account calculations - Deposit/Withdrawal/Checks
        Sub calcCheck(ByVal Type1 As String, ByVal amount As Double, ByVal bal As Double)
            Select Case Type1
                Case Is = "Deposit"
                    a_checkBalance = bal + amount
                    RaiseEvent TransSuccess("Deposit")


                Case Is = "Withdrawal"
                    If bal <= 0 Or ((bal - amount) < 0) Then
                        RaiseEvent FundsError()
                        Exit Sub
                    Else
                        a_checkBalance = bal - amount
                        RaiseEvent TransSuccess("Withdrawal")
                    End If

                Case Is = "Transfer"
                    If bal <= 0 Or ((bal - amount) < 0) Then
                        RaiseEvent FundsError()
                        Exit Sub
                    Else
                        a_checkBalance = bal - amount
                        RaiseEvent TransSuccess("Transfer")
                    End If

                Case Is = "Check"
                    If bal <= 0 Or (bal - amount < 0) Then
                        RaiseEvent FundsError()
                        Exit Sub
                    Else
                        a_checkBalance = bal - amount
                        RaiseEvent TransSuccess("Check")
                    End If
            End Select
        End Sub

        'Handles the transfer groupbox calculations
        Sub calcTrans(ByVal Type As String, ByVal amm As Double, ByVal cBal As Double, ByVal sBal As Double)
            If Type = "Savings" Then
                If sBal < 0 Or (sBal - amm) < 0 Then
                    RaiseEvent FundsError()
                    Exit Sub
                Else
                    a_savBalance = sBal - amm
                    a_checkBalance = cBal + amm
                End If
            Else
                If cBal < 0 Or (cBal - amm) < 0 Then
                    RaiseEvent FundsError()
                    Exit Sub
                Else
                    a_checkBalance = cBal - amm
                    a_savBalance = sBal + amm
                End If
            End If
        End Sub

        Sub popList(ByRef lb As ListBox, ByVal type As String)
            lb.Items.Clear()
            For i As Integer = 0 To a_Trans.GetUpperBound(0)
                If a_Trans(i) IsNot Nothing Then
                    If type = "Savings" And a_Trans(i).Type = "Savings" Then
                        If a_Trans(i).Name = "Deposit" Or a_Trans(i).Name = "Transfer from Checking" Or a_Trans(i).Name = "Transfer from Savings" Then
                            lb.Items.Add(a_Trans(i).DateNow & _
                                         "  " & a_Trans(i).Name & _
                                         "         AMOUNT->   " & FormatCurrency(a_Trans(i).Amount, 2) & _
                                         "         PREV BAL->  " & FormatCurrency((a_Trans(i).SaveBalance - a_Trans(i).Amount), 2) & _
                                         "         NEW BAL->   " & FormatCurrency(a_Trans(i).SaveBalance, 2))
                            ' There is a problem here
                        ElseIf a_Trans(i).Name = "Withdrawal" Or a_Trans(i).Name = "Transfer to Checking" Or a_Trans(i).Name = "Transfer to Savings" Or a_Trans(i).Name.substring(0, 6) = "Check " Then
                            lb.Items.Add(a_Trans(i).DateNow & _
                                         "  " & a_Trans(i).Name & _
                                         "         AMOUNT->   " & FormatCurrency(a_Trans(i).Amount, 2) & _
                                         "         PREV BAL->  " & FormatCurrency((a_Trans(i).SaveBalance + a_Trans(i).Amount), 2) & _
                                         "         NEW BAL->   " & FormatCurrency(a_Trans(i).SaveBalance, 2))
                        End If
                    ElseIf type = "Checking" And a_Trans(i).Type = "Checking" Then
                        If a_Trans(i).Name = "Deposit" Or a_Trans(i).Name = "Transfer from Checking" Or a_Trans(i).Name = "Transfer from Savings" Then
                            lb.Items.Add(a_Trans(i).DateNow & _
                                         "  " & a_Trans(i).Name & _
                                         "         AMOUNT->   " & FormatCurrency(a_Trans(i).Amount, 2) & _
                                         "         PREV BAL->  " & FormatCurrency((a_Trans(i).CheckBalance - a_Trans(i).Amount), 2) & _
                                         "         NEW BAL->   " & FormatCurrency(a_Trans(i).CheckBalance, 2))
                        ElseIf a_Trans(i).Name = "Withdrawal" Or a_Trans(i).Name = "Transfer to Checking" Or a_Trans(i).Name = "Transfer to Savings" Or a_Trans(i).Name.substring(0, 6) = "Check " Then
                            lb.Items.Add(a_Trans(i).DateNow & _
                                         "  " & a_Trans(i).Name & _
                                         "         AMOUNT->   " & FormatCurrency(a_Trans(i).Amount, 2) & _
                                         "         PREV BAL->  " & FormatCurrency((a_Trans(i).CheckBalance + a_Trans(i).Amount), 2) & _
                                         "         NEW BAL->   " & FormatCurrency(a_Trans(i).CheckBalance, 2))
                        End If
                    End If
                End If
            Next
        End Sub

      
    End Class
    ''Handles the File storing of all transactions
    Private Sub BtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        'acc1 = New Account

        Dim temp() As String = {acc1.DateNow & "," & acc1.Type & "," & _
        acc1.Amount & "," & sBal}
        Dim temp1() As String = {acc1.DateNow & "," & acc1.Type & "," & _
        acc1.Amount & "," & cBal}
        Select Case acc1.Type
            Case Is = "Savings"
                Dim sw As StreamWriter = File.AppendText("csvSAVINGS.TXT")
                sw.WriteLine(Join(temp, ","))
                sw.WriteLine(Environment.NewLine)
                sw.Close()
            Case Is = "Checking"
                Dim sw As StreamWriter = File.AppendText("csvCHECKING.TXT")
                sw.WriteLine(Join(temp1, ","))
                sw.WriteLine(Environment.NewLine)

                sw.Close()
            Case Is = "Transfer to Checking"
                Dim sw1 As StreamWriter = File.AppendText("csvCHECKING.TXT")
                Dim sw2 As StreamWriter = File.AppendText("csvSAVINGS.TXT")

                sw1.WriteLine(Join(temp1, ","))
                sw1.WriteLine(Environment.NewLine)
                sw2.WriteLine(Join(temp, ","))
                sw2.WriteLine(Environment.NewLine)
                sw1.Close()
                sw2.Close()
            Case Is = "Transfer to Savings"
                Dim sw1 As StreamWriter = File.AppendText("csvSAVINGS.TXT")
                Dim sw2 As StreamWriter = File.AppendText("csvCHECKING.TXT")

                sw1.WriteLine(Join(temp, ","))
                sw1.WriteLine(Environment.NewLine)
                sw2.WriteLine(Join(temp1, ","))
                sw2.WriteLine(Environment.NewLine)
                sw1.Close()
                sw2.Close()
        End Select
    End Sub

End Class

I am lacking the final steps on getting the file to load contents from the text files. But I guess, there is always a place for version1.2

Here a small suggestion of how to read from textfiles.
It's just a small change of what you showed us in your original post.
And if you're looking for specific information stored in the files you can simply add an If statement. See code in red.

Dim stream As FileStream = Nothing
        Dim tr As TextReader = Nothing
        Dim line As String = ""
        Dim fileInput() As String

        If NameOfAccount.Equals("Savings") Then
            stream = New FileStream("csvSAVINGS.TXT", FileMode.Open)
        ElseIf NameOfAccount.Equals("Checkings") Then
            stream = New FileStream("csvCHECKKINGS.TXT", FileMode.Open)
        End If
        tr = New StreamReader(stream)

        While tr.Peek <> -1
            line = tr.ReadLine()
            If line.Contains("string to search for") Then
                tran = New Transaction()
                fileInput = line.Split(","c)
                tran.TransactionDate = fileInput(0)
                .......
            End If
        End While

Edited 6 Years Ago by Oxiegen: n/a

This question has already been answered. Start a new discussion instead.