i am making a high score table for my whack a mole game.

variable Score on frmGame is

Public score as integer

then in frmHighScore table i have

Dim numbers As Integer

numbers = frmGame.score

however variable Numbers comes back as a empty variable for some reason.

Help?
thanks

Code in Form1...(Add Command Button (Command1))

Option Explicit

Public MyPublicInteger As Integer

Private Sub Form_Load()
Load Form2
Form2.Left = Me.Left + Me.Width
Form2.Top = Me.Top
Form2.Show
End Sub

Private Sub Command1_Click()
MyPublicInteger = 4
End Sub

Code in Form2...(Add Command Button (Command1))

Option Explicit

Private Sub Command1_Click()
MsgBox Form1.MyPublicInteger
Form1.Command1.Value = True
MsgBox Form1.MyPublicInteger
End Sub

Run and click on form2's command button and if you need to, step through it with F8...

Good Luck

i cant use a command button as the score is just passed outomatically after the game is finished :(

It's an example....

i have a public variable called SCORE which is collected as the user click on a picture of a mole. this variable is in the form (frmGame)

i want to pass this SCORE into another form ( frmHighScoreTable)
I want the program to do it automatically.

Any ideas?

As I showed you before in your original thread http://www.daniweb.com/forums/thread268844.html you need to have some code to set the variable and some code to retrieve the value and since vb is an event driven language, that code you write is more than likely to stem from an event, LIKE THE CLICK EVENT OF A COMMAND BUTTON! It will NOT just appear automatically! You have to do somecoding of some sorts!!! And as I pointed out, it was an example!!! You could use the form load event if you wish it does not matter but under some event the code must go!!!

Threads merged, please read forum rules in regards of posting

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.