Call constroctor from base class : Base Class « Class Module « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » Class Module » Base Class 
6.32.1.Call constroctor from base class
Option Strict On
 Imports System
 
 Public Class Rectangle

     Public Sub New(ByVal top As Integer, ByVal left As Integer)
         Me.top = top
         Me.left = left
     End Sub

     Public Sub DrawRectangle( )
         Console.WriteLine("Drawing Rectangle at {0}, {1}", top, left)
     End Sub

     Private top As Integer
     Private left As Integer
 End Class

 Public Class NamedRectangle 
 Inherits Rectangle

     Public Sub New(ByVal top As Integer, ByVal left As Integer, ByVal n As String)
         MyBase.New(top, left)
         RectName = n
     End Sub 'New

     Public Shadows Sub DrawRectangle( )
         MyBase.DrawRectangle( ) 
         Console.WriteLine("Writing string to the listbox: {0}", RectName)
     End Sub 
     Private RectName As String
 End Class 

 Module Module1

     Sub Main( )
         Dim As New Rectangle(510)
         w.DrawRectangle( )

         Dim lb As New NamedRectangle(2030"Hello")
         lb.DrawRectangle( )
     End Sub

 End Module
Drawing Rectangle at 5, 10
Drawing Rectangle at 20, 30
Writing string to the listbox: Hello
6.32.Base Class
6.32.1.Call constroctor from base class
6.32.2.Shadows method in base class
6.32.3.Protected base constructor
6.32.4.Call method with MyBase
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.