当前位置:编程学习 > VB >>

VB.Net中文教程(4) 易做图对象关系(4)

 

 

public Overrides Sub Dispose()

       MyBase.Dispose()

       components.Dispose()

   End Sub

  

#Region " Windows Form Designer generated code "

    ......

#End Region

   Protected Sub Form1_Click(ByVal sender As Object,

                           ByVal e As System.EventArgs)

       Dim r As New MyRoom()

       r.Show()

   End Sub

End Class

 

此程序输出:

              Room Size: 100

              Desk Size:  18

 

3. 特类别继承与易做图对象

 

   您已很熟悉父子类别关系了﹐这继承关系的另一面是易做图对象关系。例如﹐

 

ex06.bas

Imports System.ComponentModel

Imports System.Drawing

Imports System.WinForms

----------------------------------------------------

Class Room

   Private mother As MyRoom

  

   Public Sub New(ByVal mo As MyRoom)

       mother = mo

   End Sub

   Public Function GetID() As String

       GetID = mother.yourID()

   End Function

End Class

 

Class MyRoom

   Inherits Room

  

   Public Sub New()

       MyBase.New(Me)

   End Sub

   Public Function yourID() As String

       yourID = "VIP888"

   End Function

End Class

----------------------------------------------------

Public Class Form1

   Inherits System.WinForms.Form

  

   Public Sub New()

       MyBase.New()

       Form1 = Me

       This call is required by the Win Form Designer.

       InitializeComponent()

       TODO: Add any initialization after the InitializeComponent() call

   End Sub

   Form overrides dispose to clean up the component list.

   Public Overrides Sub Dispose()

       MyBase.Dispose()

      

补充:软件开发 , Vb ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,