Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

An object reference is required for the nonstatic field,method

Status
Not open for further replies.

Saturn57

Programmer
Aug 30, 2007
275
CA
Im a newby and im getting the following error in my code:
An object reference is required for the nonstatic field,method,or property 'EstimatorC.Estimate.quantityTB'

Can anyone help me on this. The code is below. Thanks in advance.

class Calculator
{
static void Method1(string[] arg)
{
//miscellaneous varibles
decimal bl; //blank length
decimal bw; //blank width
decimal bp; //blank perifery
decimal pd; //part depth
decimal dq; //die quantity
decimal.TryParse(quantityTB.Text, out dq);
decimal dl; //die length
decimal dw; //die width
decimal ds; //die shut height
decimal d; //density
decimal.TryParse(densityTB.Text, out d);
decimal wp; //work percetage of die
decimal.TryParse(dieworkareapercentageTB.Text, out wp);
decimal trl; //trim length
decimal.TryParse(lengthoftrimTB.Text, out trl);
decimal cncc; //cnc complexity
decimal dodr; //degree of difficulty rating
decimal sec;
decimal.TryParse(diesectionsTB.Text, out sec);
decimal opqty;//number of operations
decimal.TryParse(noofopsTB.Text, out opqty);
}
}
 
first, you should post the stacktrace along with the error message. the stack trace is your starting point for tracking down the error.

you are referencing objects like quantityTB.Text in the static member Method1.

I would also make 2 recomendations:
1. descriptive variable names example decimal blank_lenght instead of decimal bl. it will help when you revisit the code. no need to find the comments associated with the variable.

2. descriptive members. Method1(string[] args) tells you nothing about what it does, or what it requires.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
What is the stacktrace and where do I get it?
 
it's part of the exception.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top