Passing variable values from form to form
Author |
Message |
Igneous
|
Posted: Mon Mar 31, 2008 9:01 am Post subject: Passing variable values from form to form |
|
|
hello, im not sure if this has been posted before, but i am having trouble assinging variables from one form to another. for example i have a program structure of a game assignment i am working on at school.i decided to go with a structure as seen here:
Start MENU - Form 1
Game Engine - Form 2
Ending MENU - Form 3
now i wanted to make this trigger variable that triggers events which opens one form and terminates the other. Problem is i have no knowledge of global variables or how to delcare them (ive tried searching msdn online but no results, and it doesnt work anymore)
so i heard of a technique called passing variables, i looked in my book and found it only mentions a short paragraph about it and no info.
SO heres the theory
variable - Start_Game as boolean
now when a button is clicked on Start MENU, this variable returns a value as true and launches the game. Once the game finishes the variable goes false and then the End MENU launches. After which three buttons are displayed, return to original menu, restart game, and quit game.
Problem is with this theory i cant trigger variables from different forms because i get the error "Error 1 'Zalewski_A2.Game.g_StartGame' is not accessible in this context because it is 'Private'. F:\Zalewski_A 2\Zalewski_A1\End_Menu.vb 7 9 Zalewski_A1'
i really need some help with this ASAP, ive tried making the variable public but i get this error: "Error 1 Expression is not a method. F:\Zalewski_A 2\Zalewski_A1\End_Menu.vb 7 9 Zalewski_A1"
any help with this? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
OneOffDriveByPoster
|
Posted: Mon Mar 31, 2008 12:12 pm Post subject: Re: Passing variable values from form to form |
|
|
VisualBASIC: | Dim mEvil As Boolean
Public Function getEvil() As Boolean
getEvil = mEvil
End Function
Public Sub setEvil(evil As Boolean)
mEvil = evil
End Sub | Using getters and setters could help... |
|
|
|
|
|
|
|