Visual Basic 2013 - Form can not access / modify data from a Module

2

My problem is this. I have this module that contains an integer variable and this variable is accessed by a form that changes its value, as the code below shows.

Module Module1
       Public frm1 As New Form1
       Public frm2 As New Form2

       Public Uso As Integer
End Module

Public Class Form1
...
    Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem4.Click
        Uso = 1
        frm2 = New Form2
        frm2.MdiParent = Me
        frm2.Text = "PROJETO DE TROCADOR DE CALOR"
        frm2.Show()
    End Sub
End Class

When compiling it normally opens form1 (MdiContainer). When I try to open a new file, MenuItem4_Click , throws an exception. It says that the reference of an object was not defined for an instance of this object.

This error happens with ALL the variables in this Module1 that frm2 tries to access / modify.

I have done other programs using the same logic that never gave this bizarre error. I really need help !!!!

    
asked by anonymous 27.10.2015 / 01:10

1 answer

1

On line

frm2 = New Form2

You did not say, you just set the variable frm2 to a new Form2 , resolve this with Dim . Your code is also very incomplete, put the declaration of the variables (all) that were used in this code so we can get a better sense of the error.

    
27.10.2015 / 03:13