Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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 July 3rd, 2011, 03:44 PM
Registered User
Points: 40, Level: 1
Points: 40, Level: 1 Points: 40, Level: 1 Points: 40, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 5 - Inherits

Hello,

I just finished reading chapter 5. So, I tried to code a simple page using Student Inherits Person. I started by creating an App_Code folder. I added the class Person.vb. and coded the following:

Code:
Imports Microsoft.VisualBasic
Public Class Person
  Private _firstName As String
  Public Property FirstName As String
    Get
      Return _firstName
    End Get
    Set(ByVal value As String)
      ' force FirstName to begin with a capital letter:
      If Not String.IsNullOrEmpty(value) Then
        _firstName = value.Substring(0, 1).ToUpper _
        & value.Substring(1)
      Else
        _firstName = String.Empty
      End If
    End Set
  End Property

  Private _lastName As String
  Public Property LastName As String
    Get
      Return _lastName
    End Get
    Set(ByVal value As String)
      ' force LastName to begin with a capital letter:
      If Not String.IsNullOrEmpty(value) Then
        _lastName = value.Substring(0, 1).ToUpper _
        & value.Substring(1)
      Else
        _lastName = String.Empty
      End If
    End Set
  End Property
End Class
Next, in the App_Code folder, I created Student.vb and coded the following:

Code:
 
Imports Microsoft.VisualBasic
Public Class Student Inherits Person 
  Private _studentID As String
  Public Property StudentID As String
    Get
      Return _studentID
    End Get
    Set(ByVal value As String)
      _studentID = value
    End Set
  End Property
End Class
However, "Inherits Person" is underlined and the error description is "End of Statement expected."

Please tell me how I should correct this?
Reply With Quote
  #2 (permalink)  
Old July 3rd, 2011, 04:00 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

Take a look at page 190 and further. In VB, the Inherits keyword and the name that follows must be placed on the next line. E.g this:

Code:
 
Public Class Student 
     Inherits Person 
 
  ' Other code goes here
End Class
should work.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
MarshallN (July 7th, 2011)
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
Inherits rpcasey001 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 March 5th, 2009 11:36 PM
Inherits When Upload to ISP helga@trisyn.co.za ADO.NET 0 September 23rd, 2005 05:16 AM
Inherits sub class Brettvan1 VB.NET 2002/2003 Basics 4 June 10th, 2005 05:16 PM
Inherits the page? frej ASP.NET 1.0 and 1.1 Basics 3 June 3rd, 2005 09:26 AM
Inherits error phbrady General .NET 1 April 7th, 2004 02:15 AM



All times are GMT -4. The time now is 11:05 AM.


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