0

Hey guys,

Im quite new to vb and i've got a school project. Im making a game somewhat similar to the 'idiot test' series. I'm trying to make a counter that will count the number of clicks, which will also be displayed. I'll obviously display it with a label and i know how to make a basic counter that increases. I'm just not sure as to how to keep the integer to change over each form, because as i click a button, the majority of the time, it will change to a new form.

I got told about using a module or something, but i can't seem to work it out.

Thanks in advance
-Jarrod

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by AndreRet
0

Open a new module in your project - Click on "Project - Add New Module".

In the module code form, add the following...

Option Explicit

Public xCounterClicks As Integer

Save the module....

When your app starts up, in the form load event, add the following...

xCounterClicks = 0

Make sure this is ONLY in your startup/first form when the app starts and NOT in all your forms....

In your form under the button the user will click on, add the following to its click event...

xCounterClicks = xCounterClicks + 1

Now you just call the number to a label...

Label1.Caption = xCounterClicks
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.