CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2012
    Posts
    2

    I'm having trouble with my code

    Hey everyone. I am having trouble with writing settings from a Windows form for my game. What I'm trying to do is have the user input the screen resolution width and height in a Windows form, write it to a binary file, then open the file with the game and pass the variables to Viewport.Width and Height.

    These are the 2 errors I'm getting:

    Code:
    An object reference is required for the non-static field, method, or property 'ShovelShovel.WindowSize.Width.get'
    An object reference is required for the non-static field, method, or property 'ShovelShovel.WindowSize.Height.get'
    I'll attach my code, since I think it would be easier for anyone who could help me to see the whole code instead of just snippets.

    Thank you so much to anyone who can help me. I admit I am still a beginner, so I get confused easily...

    Game1.cs
    Settings.cs
    WindowSize.cs

  2. #2
    Join Date
    Dec 2012
    Posts
    2

    Re: I'm having trouble with my code

    Does this forum not have an edit button? I can't find it...

    Anyways, I figured it out. You can delete this thread, admins.

  3. #3
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: I'm having trouble with my code

    Quote Originally Posted by Lowena View Post
    Does this forum not have an edit button? I can't find it...
    You must have at least 5-10 post before that feature can become active - it might even be more..

    Quote Originally Posted by Lowena View Post
    Anyways, I figured it out. You can delete this thread, admins.
    Good for you. Please share your answer with your fellow forum members. It's how things work around here. Please mark your thread resolved as well.

  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: I'm having trouble with my code

    Usually we do not delete, if question could help somenone. That's why we encourage to post solution when quester itself find out.
    Error you got was about a variable instance used before being created. Sounds as if somewhere you forgot a
    Code:
    x= new theRequiredType()
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured