Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with Object Collection

Status
Not open for further replies.

MEGUIA

Programmer
Sep 26, 2001
62
PR
Hi

I'm using Visual Basic 6.0 SP5

I'm create it a class named ClsCpy that uses a collection, it's works fine when a filled the collection with data but when I called the object in the same instance doesn't bring the information.

I'm sending the class ClsCpy and the subroutine that I use to fill the collection class at the is an example on how I'm trying to get the information from the collection class.

*********************************************************
Private mvarCPYSRC As String 'local copy
Private mvarCPYDST As String 'local copy
Private mvarFLAG As Boolean 'local copy
Private mvarMvarMap As Collection 'local copy


Public Property Set MvarMap(ByVal vData As Collection)
Set mvarMvarMap = vData
End Property
Public Property Get MvarMap() As Collection
Set MvarMap = mvarMvarMap
End Property
Public Property Let FLAG(ByVal vData As Boolean)
mvarFLAG = vData
End Property
Public Property Get FLAG() As Boolean
FLAG = mvarFLAG
End Property
Public Property Let CPYDST(ByVal vData As String)
mvarCPYDST = vData
End Property
Public Property Get CPYDST() As String
CPYDST = mvarCPYDST
End Property
Public Property Let CPYSRC(ByVal vData As String)
mvarCPYSRC = vData
End Property
Public Property Get CPYSRC() As String
CPYSRC = mvarCPYSRC
End Property

Public Function MapCount() As Integer
MapCount = MvarMap.Count
End Function
Public Function AddMap(Nindex As Integer) As ClSCpy
Dim spkNew As New ClSCpy
MvarMap.Add spkNew, CStr(Nindex)
Set AddMap = spkNew
End Function
Public Sub Remove(Nindex As Integer)
Dim lLast As Long
lLast = MvarMap.Count
MvarMap.Remove CStr(Nindex)
End Sub
Public Property Get Count() As Integer
Count = MvarMap.Count
End Property

Private Sub Class_Initialize()
Set MvarMap = New Collection
End Sub

***SubRoutine that fill's the object collection

Public Sub FillObj()
Dim X As Integer
Dim J As String
Set cn = New ADODB.Connection
With cn
.ConnectionString = "oMapTble"
.CursorLocation = adUseClient
.Open
End With
X = 0
Set objcpy = New ClSCpy
Set rst = New ADODB.Recordset
rst.Open "Select * from tblmap", cn
With rst
Do While Not .EOF
X = X + 1
With objcpy
.AddMap X
.CPYDST = Trim(rst("MMAP"))
.CPYSRC = Trim(rst("MMAPD"))
.FLAG = rst("MFLAG")
End With
.MoveNext
Loop
End With
rst.Close
cn.Close

**************************************************

***Example of how do I retrieve the collection data********
dim x as integer
dim j as string
X = 0

For X = 1 To objcpy.MapCount

J = objcpy.MvarMap(X).CPYDST
Next
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top