trashed variable

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm creating a program that uses 2 windows forms. One form gets input from
the user and the other uses the input from the first form. When the second
form is instantiated the value from the first form gets trashed. How do I
get around this without using a global variable?
 
Creator,

Can you show how you are getting/setting the value? It's hard to
believe that the value is just trashed.
 
Creator said:
I'm creating a program that uses 2 windows forms. One form gets input from
the user and the other uses the input from the first form. When the second
form is instantiated the value from the first form gets trashed. How do I
get around this without using a global variable?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 
Actually, I don't believe that there is a problem with the code. The problem
is more that I am unfamiliar with C#. How do I pass a value from one form to
another?
 
Creator said:
Actually, I don't believe that there is a problem with the code. The problem
is more that I am unfamiliar with C#. How do I pass a value from one form to
another?

The same way you pass a value from any object to another.

I suggest you stop where you are in your GUI application, and start
learning C# from the basics - start with very, very simple programs
which only use the console, do a bit of file manipulation maybe, and
work your way up. GUIs have their own problems quite aside from normal
C#, and if you're unfamiliar with the language to start with, you'll
have a much harder job trying to tackle both at the same time than you
would learning just the language and a few of the more basic core
libraries first.
 
Back
Top