I've been working on my first windows program for a little while and have 2 more things I'd like to do. The program is a simple calculator that could help me with my work. I realize it's a little aggressive for me as I still have lots to learn but would like to finish it. I can live with it, but didn't think the 2 changes I wanted would be too hard until I started searching online. Here is the code for 2 buttons:
Code:private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { int start_cyl = Int32::Parse(textBox1->Text, NumberStyles::HexNumber); if (start_cyl < 0 || start_cyl > 1048575) { MessageBox::Show("Starting Cylinder must between 0 and FFFFF"); } else { int start_head = System::Int32::Parse(textBox2->Text, NumberStyles::HexNumber); if (start_head < 0 || start_head > 14) { MessageBox::Show("The start head must be between 0 and E"); } else { int start_blk = Int32::Parse(textBox3->Text, NumberStyles::HexNumber); if (start_blk < 0 || start_blk > 127) { MessageBox::Show("The start block count must be between 0 and 7F"); } else { int end_cyl = Int32::Parse(textBox4->Text, NumberStyles::HexNumber); if (end_cyl < 0 || end_cyl > 1048575) { MessageBox::Show("End Cylinder must between 0 and FFFFF"); } else { int end_head = System::Int32::Parse(textBox5->Text, NumberStyles::HexNumber); if (end_head < 0 || end_head > 14) { MessageBox::Show("The end head must be between 0 and E"); } else { int end_blk = System::Int32::Parse(textBox6->Text, NumberStyles::HexNumber); if (end_blk < 0 || end_blk > 127) { MessageBox::Show("The end block count must be between 0 and 7F"); } else { int ans = ((start_cyl * 0x80 * 0xf) + (start_head * 0x80)) + start_blk; int ans1 = ((end_cyl * 0x80 * 0xf) + (end_head * 0x80)) + end_blk; textBox7->Text = ans.ToString(); textBox8->Text = ans1.ToString(); } } } } } } } private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) { textBox1->Clear(); textBox2->Clear(); textBox3->Clear(); textBox4->Clear(); textBox5->Clear(); textBox6->Clear(); textBox7->Clear(); textBox8->Clear(); } }; }
1. I'd like the enter button to default to button one (calculate).
2. I'd like every one of my text boxes to default to 0 if no input.
This is not homework, can anyone help me out?



LinkBack URL
About LinkBacks



