View Single Post
  #7   Spotlight this post!  
Unread 19-09-2006, 17:15
MattD's Avatar
MattD MattD is offline
Registered User
AKA: Matthew Douglas
FRC #0228 (GUS Robotics)
Team Role: Alumni
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Indianapolis, IN
Posts: 185
MattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to behold
Send a message via AIM to MattD
Re: Visual C++ 2005 Forms

Quote:
Originally Posted by 6600gt
I am using C++ and yes, I am trying to share variable as well as objects, such as serialPort1, between different forms. The object is only initialized in one form but I need to use it others. Any ideas?

Thanks
I don't know how to do this in C++, but I'm sure it'd be similar to what I'd do in C#.

Create a class with a name such as Globals, with static members for everything that you need to share.
Code:
public class Globals 
{
    public static int someNumber;
    public static bool someBoolean;
   // .. etc...
}
Then those could be accessed from anywhere, using Globals.someNumber, Globals.someBoolean, etc.
__________________
GUS Robotics Team 228

2010 WPI Engineering Inspiration Award
2010 WPI Regional Champions (Thanks 230 & 20!)
2010 CT VEX Champions
2010 CT VEX Innovate Award
2009 QCC VEX Champions
2009 CT Motorola Quality Award
2007 CT J&J Sportsmanship Award
2006 CT Best Website Award