Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2008 > BOOK: Professional Visual Basic 2008 ISBN: 978-0-470-19136-1
|
BOOK: Professional Visual Basic 2008 ISBN: 978-0-470-19136-1
This is the forum to discuss the Wrox book Professional Visual Basic 2008 by Bill Evjen, Billy Hollis, Bill Sheldon, Kent Sharkey; ISBN: 9780470191361
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Visual Basic 2008 ISBN: 978-0-470-19136-1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 3rd, 2009, 06:16 PM
Registered User
 
Join Date: Aug 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Errors msg : Keyword does not name a type and name objClass is not declare

I am using this code (page 22) of your book Visual Basic Professional 2008 (Bill Evjen,Billy Hollis,Bill Sheldon,Kent Sharkey) and is not working.

Dim objMyClass As New MyClass("Hello World")
Console.WriteLine(objMyClass.ToString)

Keep receiving error as follows:

MyClass : Keyword does not name a type

objMyClass: name objClass is not declare

Thank you.
 
Old August 3rd, 2009, 10:28 PM
Registered User
 
Join Date: Apr 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default "MyClass" is a placeholder in this code

The code sample you have included is just to illustrate that *any* object instance can call a ToString method. The MyClass type hasn't been defined; it is just a placeholder for some type name of a class that is either part of the .NET framework, or which you have defined somewhere else in your project.

I must admit that the type name chosen (MyClass) is a bit unfortunate, because it's a keyword and couldn't be used as the name of a class in real code. I would have chosen something different (I didn't write this particular chapter).

However, this code was never meant to work as-is - it is just intended to illustrate a minor point, and the experienced reader is expected to understand the need to insert a real class identifier (with an appropriate constructor argument) when using the technique.

Such generic placeholders are not uncommon in snippets, because it takes so long to go through a step-by-step to do a complete example of even a fairly minor point such as usage of ToString. It would have been necessary to go through the entire procedure for defining a simple class just to make a quick point.

Keep in mind that this is a book in the Professional series, so a certain level of coding expertise and experience is assumed. If you feel that you need more detail for illustration of points like this, the Beginning series might be a better choice for you.
 
Old August 4th, 2009, 09:09 AM
Registered User
 
Join Date: Aug 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up "MyClass" IS A PLACEHOLDER IN THIS CODE

Thank you. It's been of great help.

Best regards,

Enrique Bello





Similar Threads
Thread Thread Starter Forum Replies Last Post
Receiving Error Msg:Unable to cast object of type cesemj ASP.NET 2.0 Basics 2 March 4th, 2008 02:18 PM
declare My ajkumar Visual Basic 2005 Basics 0 April 18th, 2007 05:24 AM
declare a ASP variable with a TYPE crmpicco Classic ASP Basics 1 August 17th, 2005 05:52 PM
Can't get errors to display with <html:errors> michaeldill JSP Basics 0 August 2nd, 2004 01:47 PM
Errors Errors DB Errors Ljhopkins VS.NET 2002/2003 0 July 15th, 2003 12:42 PM





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