Sure. Firstly, form1 does not close, it's hidden - there is a difference ;-)
To pass one value to another, I guess a way would be to make a public property on each form, getting and setting the values. Example:
dim theScore as Integer = 0
public property MyProperty() As Integer
get
return Me.theScore
end get
set(byval value as Integer)
Me.theScore = value
end set
end property
this would be on top of each form, just after your "class" statement/decleration. What this does is creates a property. Property exposes itself to other classes so they can access it and get or set values appropriately.
in this case, we are making a property of type Integer.
So now when you are accessing each form you would do this to SET the score:
Dim theForm as New FormNameHere()
theForm.MyProperty = ScoreHere
theForm.Show()
Me.Hide()
Remember to ADD/Subtract the score appropriately depending on the users choice in your program, and the way to do that would be:
Me.MyProperty = Me.MyProperty + Score
for example.
You could also pass the variables through the constructor of the Class and setting them, similar to above but perhaps this maybe a bit advanced for you
To do this, you would again declare a local variable, just after your class decleration:
public class Form
Dim theScore as Integer = 0
..
..
public sub New(ByVal score as Integer)
Me.theScore = score
....
end sub
and you would do the same thing when adding score etc...
Now when you create an instance of a form, you would pass it a score:
Dim theForm as new FormName(score)
theForm.Show()
Me.Hide()
hope this helps.
|