Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Passing variable values from form to form
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Igneous




PostPosted: 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
Sponsor
sponsor
OneOffDriveByPoster




PostPosted: 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...
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: