Re: where oh where is my loop?
Phil Sayers <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <[email protected]> |
change this:
Public Class Children
Inherits ArrayList
Public Overloads Sub Add(ByVal C As Child)
Me.Add(C)
End Sub
.
.
to this:
Public Class Children
Inherits ArrayList
Public Overloads Sub Add(ByVal C As Child)
Mybase.Add(C)
End Sub
change all other overloads to use mybase.
the call to Me.Add is causing a recursive codepath.
-----Original Message-----
From: Discussion forum for developers using Windows Forms to build apps
and controls [mailto:[email protected]]On Behalf Of
Stacey Levine
Sent: Thursday, May 17, 2007 1:47 PM
To: [email protected]
Subject: [DOTNET-WINFORMS] where oh where is my loop?
I have a custom arraylist called children.. That takes a class called
Child, which is inherited from Dependent. When I call that add on my
arraylist, it loops until a stack overflow and I have no idea why... any
ideas? Code is below. I am sure I a missing something easy..
unfortunately I don't have anyone else in my office that I can ask to
look at this..
This is the code that adds the item..
Dim thisChild As New Child
thisChild.FirstName = txtFirstName.Text.ToUpper
.....
formData.Children.Add(thisChild)
and formData is of a type that has the Children defined as.
Private _Children As New Children
Public Property Children() As Children
Get
Return _Children
End Get
Set(ByVal value As Children)
_Children = value
End Set
End Property
**********CHILDREN **********************
Imports System.Collections
Public Class Children
Inherits ArrayList
Public Overloads Sub Add(ByVal C As Child)
Me.Add(C)
End Sub
Public Overloads Sub Remove(ByVal C As Child)
Me.Remove(C)
End Sub
Public Overloads ReadOnly Property Item(ByVal i As Integer)
Get
Return Me.Item(i)
End Get
End Property
End Class
***********************CHILD
Imports Microsoft.VisualBasic
''' <summary>
''' Holds all the infomration about the children. ''' </summary>
''' <remarks></remarks>
Public Class Child
Inherits Dependent
Private _CollegeStudent As Boolean = False
Private _CollegeName As String = String.Empty
Private _CollegeState As String = String.Empty
Private _CollegeStartDate As Date
Private _CollegeEndDate As Date
Public Property CollegeStudent() As Boolean
Get
Return _CollegeStudent
End Get
Set(ByVal value As Boolean)
_CollegeStudent = value
End Set
End Property
Public Property CollegeName() As String
Get
Return _CollegeName
End Get
Set(ByVal value As String)
_CollegeName = value
End Set
End Property
Public Property CollegeState() As String
Get
Return _CollegeState
End Get
Set(ByVal value As String)
_CollegeState = value
End Set
End Property
Public Property CollegeStartDate() As Date
Get
Return _CollegeStartDate
End Get
Set(ByVal value As Date)
_CollegeStartDate = value
End Set
End Property
Public Property CollegeEndDate() As Date
Get
Return _CollegeEndDate
End Get
Set(ByVal value As Date)
_CollegeEndDate = value
End Set
End Property
End Class
********************DEPENDENT
Imports Microsoft.VisualBasic
Public Class Dependent
Private _FirstName As String = String.Empty
Private _MiddleInitial As String = String.Empty
Private _LastName As String = String.Empty
Private _FullName As String = String.Empty
Private _DOB As Date
Private _SSN As String = String.Empty
Private _Male As Boolean = False
Private _Female As Boolean = False
Private _DesiresMedical As Boolean = False
Private _HasOtherCoverage As Boolean = False
Private _AnotherReason As Boolean = False _false
Public Property FullName() As String
Get
Return _FullName
End Get
Set(ByVal value As String)
_FullName = value
End Set
End Property
Public Property FirstName() As String
Get
Return _FirstName
End Get
Set(ByVal value As String)
_FirstName = value
End Set
End Property
Public Property MiddleInitial() As String
Get
Return _MiddleInitial
End Get
Set(ByVal value As String)
_MiddleInitial = value
End Set
End Property
Public Property LastName() As String
Get
Return _LastName
End Get
Set(ByVal value As String)
_LastName = value
End Set
End Property
Public Property DOB() As Date
Get
Return _DOB
End Get
Set(ByVal value As Date)
_DOB = value
End Set
End Property
Public ReadOnly Property DOBMonth() As Integer
Get
Return _DOB.Month
End Get
End Property
Public ReadOnly Property DOBDay() As Integer
Get
Return _DOB.Day
End Get
End Property
Public ReadOnly Property DOBYear() As Integer
Get
Return _DOB.Year
End Get
End Property
Public Property SSN() As String
Get
Return _SSN
End Get
Set(ByVal value As String)
_SSN = value
End Set
End Property
Public ReadOnly Property SSNPart1() As String
Get
If _SSN <> String.Empty Then
Return _SSN.Substring(0, 3)
Else
Return String.Empty
End If
End Get
End Property
Public ReadOnly Property SSNPart2() As String
Get
If _SSN <> String.Empty Then
Return _SSN.Substring(3, 2)
Else
Return String.Empty
End If
End Get
End Property
Public ReadOnly Property SSNPart3() As String
Get
If _SSN <> String.Empty Then
Return _SSN.Substring(5, 4)
Else
Return String.Empty
End If
End Get
End Property
Public Property Male() As Boolean
Get
Return _Male
End Get
Set(ByVal value As Boolean)
_Male = value
End Set
End Property
Public Property Female() As Boolean
Get
Return _Female
End Get
Set(ByVal value As Boolean)
_Female = value
End Set
End Property
Public Property DesiresMedical() As Boolean
Get
Return _DesiresMedical
End Get
Set(ByVal value As Boolean)
_DesiresMedical = value
End Set
End Property
Public Property HasOtherCoverage() As Boolean
Get
Return _HasOtherCoverage
End Get
Set(ByVal value As Boolean)
_HasOtherCoverage = value
End Set
End Property
Public Property AnotherReason() As Boolean
Get
Return _AnotherReason
End Get
Set(ByVal value As Boolean)
_AnotherReason = value
End Set
End Property
End Class