Multiple forms in a Pocket PC project

James Plisken

New member
Joined
Nov 19, 2004
Messages
2
Programming Experience
1-3
I am using Visual Studio.NET 2003. Anyway, I am creating my first multiple form Pocket PC project, and 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:

VB.NET:
Dim secondForm As New form2
    secondForm.ShowDialog()

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

VB.NET:
    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.
 
James Plisken said:
I am using Visual Studio.NET 2003. Anyway, I am creating my first multiple form Pocket PC project, and 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:

VB.NET:
Dim secondForm As New form2
secondForm.ShowDialog()

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

VB.NET:
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.

I think that the variables should be declared with shared, and accessed by form1.cuenta and not frm.cuenta (you do not need to instantiate a class, like "dim frm as new form1", to access a shared variable).
 
Back
Top