Error - main.
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.CenterScreen;
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)
{
}
}
Overstående er min kode, jeg får følgende 2 fejl: Error 1
The name 'main' does not exist in the current context C:\Users\mdm\Documents\Visual Studio 2008\Projects\Project1\Project1\CodeFile1.cs 179 25 Label
- Dette er fejl 1.
Error 2 The name 'txtDisplayOutput' does not exist in the current context C:\Users\mdm\Documents\Visual Studio 2008\Projects\Project1\Project1\CodeFile1.cs 195 13 Label
Dette er fejl 2.
Angående fejl 2 kunne jeg forstille mig at txtDisplayOutput skulle hedde btn istedet for txt.
Ps. koden er fra Beginning C.Sharp 2008 - er det bare mig eller er den fyldt med fejl.
jeg bruger visual studio 2008.