Wrox Programmer Forums
|
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 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 July 3rd, 2011, 03:44 PM
Registered User
 
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?
 
Old July 3rd, 2011, 04:00 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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!
The Following User Says Thank You to Imar For This Useful Post:
MarshallN (July 7th, 2011)





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 [email protected] 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





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