Wrox Programmer Forums
|
BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3
This is the forum to discuss the Wrox book Beginning C# 3.0 : An Introduction to Object Oriented Programming by Jack Purdum; ISBN: 9780470261293
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 3rd, 2010, 11:12 AM
Registered User
 
Join Date: Mar 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default ch 3 page 58

im not getting any result..


Code:
using System;
using System.Windows.Forms;

public class frmMain : Form
{
    private Label label1;
    private Label label2;
    private TextBox txtOperand1;
    private TextBox txtOperand2;
    private TextBox txtResult;
    private Button btnExit;
    private Button btnCalc;
    #region Windows Code
    private void InitializeComponent()
    {
        this.btnCalc = new System.Windows.Forms.Button();
        this.label1 = new System.Windows.Forms.Label();
        this.label2 = new System.Windows.Forms.Label();
        this.txtOperand1 = new System.Windows.Forms.TextBox();
        this.txtOperand2 = new System.Windows.Forms.TextBox();
        this.txtResult = new System.Windows.Forms.TextBox();
        this.btnExit = new System.Windows.Forms.Button();
        this.SuspendLayout();
        // 
        // btnCalc
        // 
        this.btnCalc.Location = new System.Drawing.Point(12, 85);
        this.btnCalc.Name = "btnCalc";
        this.btnCalc.Size = new System.Drawing.Size(76, 23);
        this.btnCalc.TabIndex = 0;
        this.btnCalc.Text = "Resultat";
        this.btnCalc.UseVisualStyleBackColor = true;
        // 
        // label1
        // 
        this.label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
        this.label1.Location = new System.Drawing.Point(12, 7);
        this.label1.Name = "label1";
        this.label1.Size = new System.Drawing.Size(65, 20);
        this.label1.TabIndex = 1;
        this.label1.Text = "label1";
        // 
        // label2
        // 
        this.label2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
        this.label2.Location = new System.Drawing.Point(12, 33);
        this.label2.Name = "label2";
        this.label2.Size = new System.Drawing.Size(65, 20);
        this.label2.TabIndex = 2;
        this.label2.Text = "label2";
        // 
        // txtOperand1
        // 
        this.txtOperand1.Location = new System.Drawing.Point(82, 7);
        this.txtOperand1.Name = "txtOperand1";
        this.txtOperand1.Size = new System.Drawing.Size(100, 20);
        this.txtOperand1.TabIndex = 3;
        // 
        // txtOperand2
        // 
        this.txtOperand2.Location = new System.Drawing.Point(82, 33);
        this.txtOperand2.Name = "txtOperand2";
        this.txtOperand2.Size = new System.Drawing.Size(100, 20);
        this.txtOperand2.TabIndex = 4;
        // 
        // txtResult
        // 
        this.txtResult.Location = new System.Drawing.Point(12, 59);
        this.txtResult.Name = "txtResult";
        this.txtResult.ReadOnly = true;
        this.txtResult.Size = new System.Drawing.Size(170, 20);
        this.txtResult.TabIndex = 5;
        // 
        // btnExit
        // 
        this.btnExit.Location = new System.Drawing.Point(106, 85);
        this.btnExit.Name = "btnExit";
        this.btnExit.Size = new System.Drawing.Size(76, 23);
        this.btnExit.TabIndex = 6;
        this.btnExit.Text = "button2";
        this.btnExit.UseVisualStyleBackColor = true;
        // 
        // frmMain
        // 
        this.ClientSize = new System.Drawing.Size(194, 113);
        this.Controls.Add(this.btnExit);
        this.Controls.Add(this.txtResult);
        this.Controls.Add(this.txtOperand2);
        this.Controls.Add(this.txtOperand1);
        this.Controls.Add(this.label2);
        this.Controls.Add(this.label1);
        this.Controls.Add(this.btnCalc);
        this.Name = "frmMain";
        this.Load += new System.EventHandler(this.frmMain_Load);
        this.ResumeLayout(false);
        this.PerformLayout();

    }
    #endregion

    public frmMain()
    {
        InitializeComponent();
    }


    private void btnCalc_Click(object sender, EventArgs e)
    {
        bool flag;
        int operand1;
        int operand2;
        int answer;
        // Input Step
        // Check first input...
        flag = int.TryParse(txtOperand1.Text, out operand1);
        if (flag == false)
        {
            MessageBox.Show("Enter a whole number", "Input Error");
            txtOperand1.Focus();
            return;
        }
        // Check second input...
        flag = int.TryParse(txtOperand2.Text, out operand2);
        if (flag == false)
        {
            MessageBox.Show("Enter a whole number", "Input Error");
            txtOperand2.Focus();
            return;
        }
        // Process Step
        answer = operand1 / operand2;
        // Display Step
        txtResult.Text = operand1.ToString() + " divided by " +
                operand2.ToString() +
                " equals " + answer.ToString();
        txtResult.Visible = true;
    }
    private void btnExit_Click(object sender, EventArgs e)
    {
        Close();
    }

    public static void Main()
    {
        frmMain main = new frmMain();
        Application.Run(main);
    }



    private void frmMain_Load(object sender, EventArgs e)
    {

    }


}

where is the problem?
 
Old March 3rd, 2010, 11:34 AM
Registered User
 
Join Date: Mar 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i found the solution ..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Big problem discovered at page 58 "Creating Simple Links" Antares BOOK: Beginning HTML, XHTML, CSS, and JavaScript 6 February 23rd, 2010 07:25 PM
Error code in page 58(PDF) line 7 patriot074 BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 5 April 30th, 2009 08:17 PM
CH 5 Page 153 zamankazi BOOK: ASP.NET Website Programming Problem-Design-Solution 8 November 4th, 2004 08:38 AM
PhilePage Class on p. 58 JeffSpitzer BOOK: ASP.NET Website Programming Problem-Design-Solution 0 February 8th, 2004 09:08 AM
Page 58 - Class or Classlibrary? stuckish BOOK: ASP.NET Website Programming Problem-Design-Solution 1 February 8th, 2004 09:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.