So I have 2 forms and a class, on my 1st form, it adds items to a dictionary and on my second form it checks if the item that is supposed to be added on dictionary is successful. But the weird thing is, in form 1, it shows that the item is added in the dictionary but in my 2nd form, when I get the count of dictionary, it produces 0 which means there's nothing in there. Hope you could help me with this.
Form 1
Public Class register
Dim acc_num As New System.Text.StringBuilder()
Dim account_info As New ArrayList()
Dim access_acc As New Accounts
Private Sub btn_save_Click(sender As Object, e As EventArgs) Handles btn_save.Click
Try
account_info.Add(fname_txt.Text & " " & lname_txt.Text)
account_info.Add("0.00")
access_acc.addAcc(account_number_lbl.Text, account_info)
MsgBox("Your account has been registered! Thank you for banking with us, your money is in good hands")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class
Form 2
Dim access_acc As New Accounts
Private Sub btn_process_Click(sender As Object, e As EventArgs) Handles btn_process.Click
MsgBox(access_acc.getCount().ToString)
End Sub
My Class
Public Class Accounts
Private account As New Dictionary(Of String, ArrayList)
Public Sub addAcc(ByVal account_number As String, account_info As ArrayList)
account.Add(account_number, account_info)
MsgBox(account.Count)
End Sub
Public Function getCount() As Integer
Return account.Count
End Function
End Class