An object reference is required for ....

Don't think I've seen this before

Page 1 of 1

2 Replies - 2358 Views - Last Post: 10 November 2008 - 11:43 PM Rate Topic: -----

#1 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

An object reference is required for ....

Posted 10 November 2008 - 09:15 PM

This is weird, I got a form (Main), on the form I have 2 TextBoxes, a RichTextBox and a button. When I tried

int num = Convert.ToInt32(txtNumTimes.Text);



I get this error

Quote

Error 1 An object reference is required for the nonstatic field, method, or property 'HostPing.Main.txtNumTimes'


I even deleted the TextBox in question and re-added it. This is happening with every TextBox on the form. Anyone ever had this happen? If so, how did you resolve it?

Is This A Good Question/Topic? 0
  • +

Replies To: An object reference is required for ....

#2 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: An object reference is required for ....

Posted 10 November 2008 - 11:38 PM

I just dropped a textbox on one of my test projects and copied your statement to the form_load() method, changing only the textbox name. no problemo. Have you tried adding this. to the textbox name?

This post has been edited by n8wxs: 10 November 2008 - 11:39 PM

Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: An object reference is required for ....

Posted 10 November 2008 - 11:43 PM

Yeah I tried that and was told it wasn't a valid statement. I ended up deleting the form and starting over. Go figure eh :crazy:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1