Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

Need help with GUI/CLR + classes

$
0
0

So im using visual basic C++ GUI (playing around) and started making a calculator.

So most of the code is in the .h file, I can put it here but its super long so I was wondering where do I place my classes.

In the .h file I tried putting the class before

#pragma endregion

	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
				 Lblcalc->Text = "+";

	}

but seem to get an error

Another question about classes

for my to display the number in the label I need to write this

	private: System::Void Btn1_Click(System::Object^  sender, System::EventArgs^  e) {

				 if (Lblcalc->Text == "0"){

					 Lblcalc->Text = "1";
				 }
				 else {
					 Lblcalc->Text = Convert::ToInt32(Lblcalc->Text) + "1";
				 }

but can i create a class and do this instead :

class numbers{


public:
	void num();




};

numbers::num(int x){

	if (Lblcalc->Text == "0"){

		Lblcalc->Text = x;
	}<var>else</var> {
		Lblcalc->Text = Convert::ToInt32(Lblcalc->Text) +x;
	}

then just do this :

private: System::Void Btn1_Click(System::Object^  sender, System::EventArgs^  e) {

numbers one
one.num(1)

}




Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>