monkeyboy2009
Programmer
- May 20, 2009
- 1
Hi, I'm not a very knowledgable programmer in visual C++, as I've only learned from my Programming12 class which started in February. I hope that I can provide as much information as I can to help you understand my problem better. Thank you in advance for all of your help.
A bit about my program:
- It is a "Store" application, so I have Items and the user inputs the amount of money they have, and they buy which items they want accordingly. If they spend too much, when they try to go to the checkout, a messagebox tells them they have spent too much and must redo.
- I have 3 forms: "Form1", "Inventory", and "Checkout".
- I want to pass information between each (Prices/Quantities Bought/User's Name, etc.
To change forms, I was using:
and calling frm2 on the MAIN form (Form1), and on the "Inventory" form, I was using
I was having problems with that, so I decided to just use the following code to deal with it:
This was to Change the Form1, and hide it behind the new form.
Then I would use this:
To show the 2nd form (Inventory)
Going between the Form1 and the Inventory forms was okay, but I can't seem to get to the 3rd form (Checkout) at all. I keep getting the error described in the title: "An unhandled exception of type 'System.NullReferenceException' occurred in System.Windows.Forms.dll Additional information: Object reference not set to an instance of an object."
Is there a better way I can go between forms than the ways described? How can I fix that error?
Any help will be much appreciated. I will provide as much information as necessary for you to understand better.
Thank you again,
Monkeyboy2009
A bit about my program:
- It is a "Store" application, so I have Items and the user inputs the amount of money they have, and they buy which items they want accordingly. If they spend too much, when they try to go to the checkout, a messagebox tells them they have spent too much and must redo.
- I have 3 forms: "Form1", "Inventory", and "Checkout".
- I want to pass information between each (Prices/Quantities Bought/User's Name, etc.
To change forms, I was using:
Code:
Inventory^ frm2 = gcnew Inventory();
and calling frm2 on the MAIN form (Form1), and on the "Inventory" form, I was using
Code:
Form^ frm1 = Application::OpenForms["Form1"];
I was having problems with that, so I decided to just use the following code to deal with it:
Code:
this->Size = System::Drawing::Size(124,20);
this->CenterToScreen();
this->TopMost = false;
This was to Change the Form1, and hide it behind the new form.
Then I would use this:
Code:
frm2->Show();
frm2->TopMost = true;
To show the 2nd form (Inventory)
Going between the Form1 and the Inventory forms was okay, but I can't seem to get to the 3rd form (Checkout) at all. I keep getting the error described in the title: "An unhandled exception of type 'System.NullReferenceException' occurred in System.Windows.Forms.dll Additional information: Object reference not set to an instance of an object."
Is there a better way I can go between forms than the ways described? How can I fix that error?
Any help will be much appreciated. I will provide as much information as necessary for you to understand better.
Thank you again,
Monkeyboy2009