
Migrating to System.Collections.IEnumerator from VB6.Collection
Hello:
I have been attempting to introduce the IEnumerator interface to replace all
the VB6.Collection objects in my migrated VB6 code. Having previously been
a delphi programmer I am estatic about the .Net platform, however, i am
having some difficulty due to the lack of examples in the MS .NET help.
Something Borland was very good about - eventually... Anyway, looking at
this site in C# has been a help
http://www.*-*-*.com/
description for an optimized implementation of the IEnumerator interface
which overrides the GetEnumerator Method has me stumped in VB syntax. I am
including the code below which appears not to work. Also, assuming i get
this code working I am not sure how to .Add an object to the Enumerator. Any
help or examples or links to working code would be appreciated.
Thanks,
Mark Staelens
CA - VortalLogic
Public Class VLGenProperties
Implements IEnumerable
Private objGenProperty As EnumGenProperty
'Public Function GetEnumerator() As EnumGenProperty
' GetEnumerator = New EnumGenProperty()
'End Function
Public Function GetEnumerator() As Collections.IEnumerator Implements
System.Collections.IEnumerable.GetEnumerator
GetEnumerator = New EnumGenProperty()
End Function
End Class
Public Class EnumGenProperty
Implements IEnumerator
Private Obj As VLGenProperty
Private Cursor As Integer
ReadOnly Property Current() As Object Implements IEnumerator.Current
Get
Current = Obj
End Get
End Property
Public Sub Reset() Implements System.Collections.IEnumerator.Reset
Cursor = -1
End Sub
Public Function MoveNext() As Boolean Implements
System.Collections.IEnumerator.MoveNext
If Cursor > 0 Then cursor = cursor + 1
End Function
Public Function Enumerator() As VLGenProperty
Enumerator = New VLGenProperty()
End Function
End Class
Public Class VLGenProperty
Public Enum enumVariableType
varInteger = 2
varLong = 3
varSingle = 4
varDouble = 5
varCurrency = 6
varDate = 7
varString = 8
varDecimal = 14
End Enum
Private mstrVariableName As String
Private menumVariableType As enumVariableType
Public Property VariableName() As String
Get
Return mstrVariableName
End Get
Set
mstrVariableName = VariableName
End Set
End Property
Public Property VariableType() As enumVariableType
Get
Return menumVariableType
End Get
Set
menumVariableType = VariableType
End Set
End Property
End Class