Calculator help
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: Calculator help

  1. #1
    Join Date
    Jul 2014

    Calculator help

    I am trying to make a calculator and i need some help to complete it!My code has not errors but for some reason it doesn't work correctly!My form contains 7 buttons and 3 textboxes!When i compile my code i cant see any result!

    		int first;
    		int second;
    		int result;
           #pragma endregion
    	private: System::Void button7_Click(System::Object^  sender, System::EventArgs^  e) {
    private: System::Void button5_Click(System::Object^  sender, System::EventArgs^  e) {
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
    private: System::Void textBox1_TextChanged(System::Object^  sender, System::EventArgs^  e) {
    			int temp;
    				first= Convert::ToInt32(textBox1->Text);
    private: System::Void textBox2_TextChanged(System::Object^  sender, System::EventArgs^  e) {
    			int temp;
    				second= Convert::ToInt32(textBox2->Text);

  2. #2
    Join Date
    Jun 2010

    Re: Calculator help

    Well, you don't actally explain what your code shoud do which in fact it does not. The term "Calculator" you mention gives a very vague idea of the direction your intentions are heading to, but that's by far not enough. There's so many variations of the Calculator theme out there; it's pretty much like you're coming to a musician's forum and then posting somthing like: "I wanna make music, please tell me the chords."

    It's great that you're using code tags; many new forum members fail to do so, and even some members around here for quite some time, who definitly should know better, fail to do so. However, omission of code tags ruins readability and understandability of code that once originally was understandable, which unfortunately isn't the case for your code. Control names of button1 to button7 and textBox1 to textBox3 don't really give us more information other than that you have seven buttons and three text boxes. Of what practical use could that information ever be for us? Three variables of type int named first, second and result don't really improve understandability either, at least not as long as the rest remains so obscure.

    Imagine this code of yours would actually do what you expect it to. Then, after a year or two of flawless operation of that code, while you have done a lot of other programming in the meantime, you'd get back to this code to make a few improvements. Seriously, do you really think you'd understand your own code then if it looks like this?

    Finally, "for some reasons it doesn't work correctly" may, among a bunch of others, mean any of these things (or a combinstion of these), listed exemplarily:
    • A form with controls on it that does silly things. In this case: silly in which way, i.e. how does behavior differ from what you expected?
    • A form with controls on it that simply does nothing when actually it shoud,
    • an empty form without any controls on it when actually there should be some,
    • no form at all,
    • your entire Windows systsm terribly crashing...

    So you see, we need much more, and in particular more specific information to be able to provide reasonsble help to you. You may also simplify our search for help by isolating the problem in a smaller, more concrete part of your code than the general "simply doesn't work" by using Visual Studio's built-in debugger. Have you made any attempts into this direction?
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


HTML5 Development Center