Question Passing a counter from one form to the next

batsiraigurure

New member
Joined
Mar 23, 2010
Messages
3
Programming Experience
Beginner
Hi guys
i am a new vb.net 2005 user and new to this forum.i need to know how u can pass a counter from one form to the next.am developing a computer based test and questions are on different forms so i need to know how the mark for a test can be maintained and added to from one form to the next.
 
Easiest way would be to set up a setting. Then you can access it like this:
VB.NET:
my.settings.your variable here = value
 
Setting won't do it. One way would be to create a global variable for your counter. Create a new Module by clicking Project/Add Module, and declare the variable there using Public instead of Dim.

Another way is to reference your variable from one form by using the fully qualified name. First make sure you have used the Public keyword. For example:

In form 1, named frmOne, declare a form-level variable:
Public counter As Integer

In form 2, refer to the counter as follows:

frmOne.counter += 1
 
Back
Top