Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Stephens' Visual Basic Programming 24-Hour Trainer
This is the forum to discuss the Wrox book Stephens' Visual Basic Programming 24-Hour Trainer by Rod Stephens; ISBN: 978-0-470-94335-9
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Stephens' Visual Basic Programming 24-Hour Trainer section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 28th, 2011, 11:50 PM
Authorized User
Points: 195, Level: 3
Points: 195, Level: 3 Points: 195, Level: 3 Points: 195, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Location: Tennessee
Posts: 46
Thanks: 27
Thanked 0 Times in 0 Posts
Default Ex 24-3 question

I am getting errors while fleshing out the Player class. With my class like this:

Code:
Public Class Player

    ' Declare the Name
    Public Property Name As String

    ' Create the backing variable for Points
    Private _Points As Integer
    ' Define the Points property
    Public Property Points As Integer

    ' Return the Level (Points\10)
    Public ReadOnly Property Level As Integer
        Get

        End Get
    End Property
End Class
I am receiving this error:

"variable '_Points' conflicts with a member implicitly declared for property 'Points' in class 'Player'."

and I do not have the Get and Set procedures created for me.

When I comment out the "Private _Points As Integer" line so I can at least use the automatic creation of the Get and Set procedures I still do not get them. I then created the Level Property and the automatic creation worked fine. I tried the Points Property again and still got nothing. Apparently I am missing something but I cannot figure it out. I am using Visual Studio Express. Help, please. Thank you.

Keith Z.
Reply With Quote
  #2 (permalink)  
Old September 29th, 2011, 09:38 AM
Rod Stephens's Avatar
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Hi Keith,
"variable '_Points' conflicts with a member implicitly declared for property 'Points' in class 'Player'."
I'm not sure about this but it sounds like it's trying to create auto-generated property procedures for you and it's creating a variable named _Points behind the scenes. Then when you create your variable with that name, it's getting confused because there are two variables with the same name.

(If you're feeling daring, you could peek inside the auto-generated code to see if there's a variable named _Points in there.)

Try commenting out the variable. Then go to the end of the property declaration and press Enter to see if the code editor can make the property get and set procedures. If so, uncomment your variable and you should be back in business.

If that doesn't work, let me know and perhaps email me the project and I'll look more closely.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
Reply With Quote
The Following User Says Thank You to Rod Stephens For This Useful Post:
zavodney (September 29th, 2011)
  #3 (permalink)  
Old September 29th, 2011, 01:41 PM
Authorized User
Points: 195, Level: 3
Points: 195, Level: 3 Points: 195, Level: 3 Points: 195, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Location: Tennessee
Posts: 46
Thanks: 27
Thanked 0 Times in 0 Posts
Default

I tried commenting out the _Points line and it didn't help. I put the code in Level.Get to remove the warning and that didn't help. I'll try deleting the class and recreating it just in case something got stuck. If that doesn't work I'll try deleting the whole project and start over. Thank you.

Keith
Reply With Quote
  #4 (permalink)  
Old September 29th, 2011, 02:29 PM
Rod Stephens's Avatar
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

You might also try commenting out the _Points variable. Then refer to _Points somewhere in the code. If it will let you do that, click on that reference and press F12. That should take you to the code that defines the symbol. Perhaps you can figure out where it is squirreled away.

You could also try using the Object Browser (look in the View menu) to see if you can find _Points defined somewhere.

I wonder if it was automatically created somewhere but then forgotten by the development environment so it can only sort of find it now
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
Reply With Quote
The Following User Says Thank You to Rod Stephens For This Useful Post:
zavodney (September 29th, 2011)
  #5 (permalink)  
Old September 29th, 2011, 08:27 PM
Authorized User
Points: 195, Level: 3
Points: 195, Level: 3 Points: 195, Level: 3 Points: 195, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Location: Tennessee
Posts: 46
Thanks: 27
Thanked 0 Times in 0 Posts
Default

I commented out the _Points declaration and then tried to access it later. Could not access it. I created a new project and the first entry was to declare the Points property. Still no auto creation. I then tried the names PPoints and PlayerPoints and still no auto creation. I then created the Level property and the Get was provided automatically. Both of these properties were integers so I have to assume that I am infringing on some predefined Object. The downloaded code works fine. I didn't see anything in the Object Browser about PlayerPoints. Here's the code I used:

Code:
Public Class Player

    ' Create the Points property
    Public Property PlayerPoints As Integer


    ' This is created after the POINTS property to 
    ' see if it works on something else.
    ' Return the Level (Point \ 10)
    Public ReadOnly Property Level As Integer
        Get

        End Get
    End Property

End Class
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hosed on page 24 hshlom BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 0 August 7th, 2011 10:24 PM
Chapter 24: Using ITC mparquette BOOK: Excel 2007 VBA Programmer's Reference ISBN: 978-0-470-04643-2 0 February 11th, 2010 08:55 PM
splitting large value 2^24 scoobie C++ Programming 0 November 27th, 2005 03:52 PM
Question about the CMS, Odd admin 24/7 Tdelamor BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 September 30th, 2005 07:30 PM
Code of Chapter 24 qazi_nomi BOOK: Beginning ASP 3.0 0 June 23rd, 2004 11:48 PM



All times are GMT -4. The time now is 04:38 AM.


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