Results 1 to 4 of 4

Thread: Sub Classes?

Threaded View

  1. #1

    Thread Starter
    Addicted Member Dmyze's Avatar
    Join Date
    Mar 2002
    Location
    Seattle
    Posts
    160

    Sub Classes?

    I don't know how to do this, but this is what I want to do in code:

    Code:
    Dim oWeek as new FiscalWeek(iWeekNumber, iYearNumber)
    
    iWeek = oWeek.CurrentWeek.WeekNumber
    iYear = oWeek.CurrentWeek.YearNumber
    iNextWeek = oWeek.NextWeek.WeekNumber
    iLastWeek = oWeek.NextWeek.YearNumber
    I can "kinda" do it by making a class inside a class:

    Code:
    Public Class FiscalWeek
    
    
      Private Shared iNextWeek As Integer
      Private Shared iLastWeek As Integer
      Private Shared iCurrentWeek As Integer
      Private Shared iNextYear As Integer
      Private Shared iLastYear As Integer
    
      Public CurrentWeek As New cCurrentWeek()
      Public NextWeek As New cNextWeek()
    
      Class cCurrentWeek
    
        Public ReadOnly Property WeekNumber() As Integer
    
          Get
            Return iCurrentWeek
          End Get
    
        End Property
    
        Public ReadOnly Property YearNumber()
    
          Get
            Return iCurrentYear
          End Get
    
        End Property
    
      End Class
    
      Public Class cNextWeek
    
        Public ReadOnly Property WeekNumber() As Integer
    
          Get
            Return iNextWeek
          End Get
    
        End Property
    
        Public ReadOnly Property YearNumber()
    
          Get
            Return iNextYear
          End Get
    
        End Property
    This was working pretty much, but I've found when I created two seperate instances of oWeek the Current week gets changed in both when I change it in one. it dosn't make sense to me, but I must be doing this wrong, what is the propper way to have a "nested property"?
    Last edited by Dmyze; Jan 13th, 2003 at 05:35 PM.
    -Daryl
    "Two More Rolls of Duct tape, and the world is mine!"
    VB.NET Guru

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width