I like to cancel an event if there is an error, so the rest of the code won’t run.
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {if(textBox1->Text == "")//cancel event
}
If the text of the textBox1 is empty the event exit so the rest of the code wont run and doesn’t create an error.
I do it like this, but is there a better solution to this?
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { if(textBox1->Text == "") Error = 1;
if(Error == 0)//Rest of the code);
}
Thank you.
Imi007
Just ‘return;’ that would work