Demonstrate an object with member object reference : Class Combination « 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 » Class Combination 
6.17.1.Demonstrate an object with member object reference
Module Tester

   Sub Main()
      Dim employee As New CEmployee_
         "Bob""Jones"72419493121988)

      Console.WriteLine(employee.ToStandardString())
   End Sub 

End Module 


Class CDay
   Inherits Object

   Private mMonth As Integer ' 1-12
   Private mDay As Integer ' 1-31 based on month
   Private mYear As Integer ' any year

   Public Sub New(ByVal monthValue As Integer, _
      ByVal dayValue As Integer, ByVal yearValue As Integer)

      mMonth = monthValue
      mYear = yearValue
      mDay = dayValue

   End Sub 
   ' create string containing month/day/year format
   Public Function ToStandardString() As String
      Return mMonth & "/" & mDay & "/" & mYear
   End Function ' ToStandardString

End Class 


Class CEmployee
   Inherits Object

   Private mFirstName As String
   Private mLastName As String
   Private mBirthDate As CDay ' member object reference
   Private mHireDate As CDay ' member object reference

   Public Sub New(ByVal firstNameValue As String, _
      ByVal lastNameValue As String, _
      ByVal birthMonthValue As Integer, _
      ByVal birthDayValue As Integer, _
      ByVal birthYearValue As Integer, _
      ByVal hireMonthValue As Integer, _
      ByVal hireDayValue As Integer, _
      ByVal hireYearValue As Integer)

      mFirstName = firstNameValue
      mLastName = lastNameValue

      mBirthDate = New CDay(birthMonthValue, birthDayValue, _
         birthYearValue)

      mHireDate = New CDay(hireMonthValue, hireDayValue, _
         hireYearValue)
   End Sub ' New

   Public Function ToStandardString() As String
      Return mLastName & ", " & mFirstName & " Hired: " _
         & mHireDate.ToStandardString() " Birthday: " & _
         mBirthDate.ToStandardString()
   End Function ' ToStandardString

End Class
Jones, Bob Hired: 3/12/1988 Birthday: 7/24/1949
6.17.Class Combination
6.17.1.Demonstrate an object with member object reference
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.