2 More Things??

This is a discussion on 2 More Things?? within the Windows Programming forums, part of the Platform Specific Boards category; I've been working on my first windows program for a little while and have 2 more things I'd like to ...

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    76

    2 More Things??

    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?

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    1) Does the windows form not allow you to set a default pushbutton?

    2) Just set them to 0 when creating the form.

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    76
    WOW, I thought it would be much harder than that, thanks a lot. Of course now there's one more thing. When I press clear is there a way to set all textboxes back to 0?

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Feed each one a 0, instead of emptying it's content in your button2_click routine.
    Last edited by CommonTater; 02-19-2011 at 08:01 PM.

  5. #5
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,635
    FYI, this is the wrong forum. This is about native Windows coding, and not managed.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User
    Join Date
    May 2010
    Posts
    76
    Quote Originally Posted by Elysia View Post
    FYI, this is the wrong forum. This is about native Windows coding, and not managed.
    I'm sorry, is this just C++? I thought since I was making a windows app it belon ged here.

  7. #7
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,635
    It's for native, ie C/C++. Managed goes into the C# forum typically.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Ahhh... Thanks Elysia, noted for future.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Assistance with unknown errors?
    By westside222 in forum C++ Programming
    Replies: 9
    Last Post: 11-13-2009, 08:00 PM
  2. Suggestions for things to study
    By Mastadex in forum Windows Programming
    Replies: 5
    Last Post: 08-18-2008, 09:23 AM
  3. Plants that eat things
    By StinkyRyan in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 07-05-2004, 03:41 PM
  4. How are things looking
    By cyberCLoWn in forum C++ Programming
    Replies: 8
    Last Post: 01-15-2004, 01:53 PM
  5. Help with these three things...
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 08-26-2001, 07:05 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21