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 2nd, 2010, 05:12 AM
Registered User
 
Join Date: Mar 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error page 44

im gettin 2 errors: The name 'main' does not exist in the current context and Error 2 The name 'txtDisplayOutput' does not exist in the current context

and the code is:


using System;
using System.Windows.Forms;

public class frmMain : Form
{
private Label label2;
private Label label3;
private Label label4;
private Label label5;
private TextBox txtName;
private TextBox txtAddress;
private TextBox txtCity;
private TextBox txtState;
private TextBox txtZip;
private TextBox txtResult;
private Button btnDisplayOutput;
private Button btnExit;
private Label label1;
#region Windows Code
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.txtName = new System.Windows.Forms.TextBox();
this.txtAddress = new System.Windows.Forms.TextBox();
this.txtCity = new System.Windows.Forms.TextBox();
this.txtState = new System.Windows.Forms.TextBox();
this.txtZip = new System.Windows.Forms.TextBox();
this.txtResult = new System.Windows.Forms.TextBox();
this.btnDisplayOutput = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(75, 20);
this.label1.TabIndex = 0;
this.label1.Text = "Navn:";
//
// label2
//
this.label2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label2.Location = new System.Drawing.Point(12, 29);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(75, 20);
this.label2.TabIndex = 1;
this.label2.Text = "Adresse:";
//
// label3
//
this.label3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label3.Location = new System.Drawing.Point(12, 49);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(75, 20);
this.label3.TabIndex = 2;
this.label3.Text = "By:";
//
// label4
//
this.label4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label4.Location = new System.Drawing.Point(199, 49);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(40, 20);
this.label4.TabIndex = 3;
this.label4.Text = "Stat:";
//
// label5
//
this.label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label5.Location = new System.Drawing.Point(301, 49);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(50, 20);
this.label5.TabIndex = 4;
this.label5.Text = "Post nr:";
//
// txtName
//
this.txtName.Location = new System.Drawing.Point(93, 7);
this.txtName.Name = "txtName";
this.txtName.Size = new System.Drawing.Size(312, 20);
this.txtName.TabIndex = 5;
//
// txtAddress
//
this.txtAddress.Location = new System.Drawing.Point(93, 29);
this.txtAddress.Name = "txtAddress";
this.txtAddress.Size = new System.Drawing.Size(312, 20);
this.txtAddress.TabIndex = 6;
//
// txtCity
//
this.txtCity.Location = new System.Drawing.Point(93, 49);
this.txtCity.Name = "txtCity";
this.txtCity.Size = new System.Drawing.Size(100, 20);
this.txtCity.TabIndex = 7;
this.txtCity.TextChanged += new System.EventHandler(this.txtCity_TextChanged);
//
// txtState
//
this.txtState.Location = new System.Drawing.Point(245, 49);
this.txtState.Name = "txtState";
this.txtState.Size = new System.Drawing.Size(50, 20);
this.txtState.TabIndex = 8;
//
// txtZip
//
this.txtZip.Location = new System.Drawing.Point(357, 49);
this.txtZip.Name = "txtZip";
this.txtZip.Size = new System.Drawing.Size(48, 20);
this.txtZip.TabIndex = 9;
//
// txtResult
//
this.txtResult.Location = new System.Drawing.Point(12, 105);
this.txtResult.Multiline = true;
this.txtResult.Name = "txtResult";
this.txtResult.ReadOnly = true;
this.txtResult.Size = new System.Drawing.Size(385, 145);
this.txtResult.TabIndex = 10;
//
// btnDisplayOutput
//
this.btnDisplayOutput.Location = new System.Drawing.Point(12, 76);
this.btnDisplayOutput.Name = "btnDisplayOutput";
this.btnDisplayOutput.Size = new System.Drawing.Size(86, 23);
this.btnDisplayOutput.TabIndex = 11;
this.btnDisplayOutput.Text = "&Display";
this.btnDisplayOutput.UseVisualStyleBackColor = true;
this.btnDisplayOutput.Click += new System.EventHandler(this.btnDisplayOutput_Click);
//
// btnExit
//
this.btnExit.Location = new System.Drawing.Point(319, 75);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(86, 23);
this.btnExit.TabIndex = 12;
this.btnExit.Text = "E&xit";
this.btnExit.UseVisualStyleBackColor = true;
//
// frmMain
//
this.ClientSize = new System.Drawing.Size(409, 262);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnDisplayOutput);
this.Controls.Add(this.txtResult);
this.Controls.Add(this.txtZip);
this.Controls.Add(this.txtState);
this.Controls.Add(this.txtCity);
this.Controls.Add(this.txtAddress);
this.Controls.Add(this.txtName);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "frmMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScree n;
this.Load += new System.EventHandler(this.frmMain_Load);
this.ResumeLayout(false);
this.PerformLayout();

}
#endregion

public frmMain()
{
InitializeComponent();
}

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

private void btnDisplayOutput_Click(object sender, EventArgs e)
{
String buffer;

buffer = "Mailing Label:" + Environment.NewLine +
Environment.NewLine;
buffer = buffer + " Name: " + txtName.Text +
Environment.NewLine;
buffer = buffer + "Address: " + txtAddress.Text +
Environment.NewLine;
buffer = buffer + " City: " + txtAddress.Text +
" State: " + txtState.Text +
" Zip: " + txtZip.Text;
txtDisplayOutput.Text = buffer;
}

private void txtCity_TextChanged(object sender, EventArgs e)
{

}

private void frmMain_Load(object sender, EventArgs e)
{

}
}
 
Old March 2nd, 2010, 08:36 AM
Registered User
 
Join Date: Mar 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i found the problem..


public frmMain()
{
InitializeComponent();
}

public static void Main()
{
frmMain mail = new frmMain(); - - frmMain main = new frmMain(); instead..

Application.Run(main);
}


and instead of the txtDisplayOutput i used the txtResult.Text





Similar Threads
Thread Thread Starter Forum Replies Last Post
Part 1 - page 44 Shontal BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 1 September 1st, 2009 10:38 PM
How to give a unique id like that 15b85c2b-83ca-44 vishnu108mishra XML 2 November 28th, 2007 06:44 PM
Error page youyou_hym Dreamweaver (all versions) 1 June 2nd, 2005 03:59 PM
Phile Page error, visual studio error reps BOOK: ASP.NET Website Programming Problem-Design-Solution 0 September 27th, 2003 10:11 AM





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