Problem with multiple form proyect

James Plisken

New member
Nov 19, 2004
Programming Experience
Problem with multiple form project

I already posted this on the .NET compact framework forum, but since it might also apply to to general VS.NET discussion (this is my first project using Visual Studio, it might be the same with a Windows proyect). Anyway, I am using Visual Studio.NET 2003 to create a Pocket PC project. I am having trouble accessing any variables from the first form of the project. I have 4 forms, and each one loads when I press a particular button. Example: Form 1 is the form that automatically loads once I open the program, and once inside this form I press a button and it takes me to Form 2, etc. I use the following method to open each form:

Dim secondForm As New form2

Once I'm in the fourth form, I use the following lines to try to access the variables created in the first form:

       Dim frm As form1
       Dim x As Int32
       x = frm.cuenta  ' This is where I get a NullReferenced Exception

The variables in Form 1 are all global and public, but I still can't access them. I have tried using the debugger to get a clearer error message, but for some reason the debugger sometimes fails to load up. Please help.
Last edited:


VB.NET Forum Moderator
Staff member
Jun 3, 2004
Lansing, MI; USA
Programming Experience
i recamend makeing the variables public in a standard module (only the variables that will be used on multiple forms) so that the variables are always accessable from any of the forms it needs to be accessed from.
Top Bottom