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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please Help!!

Status
Not open for further replies.

chris6user

Programmer
Dec 10, 2001
56
CA
This is a code from my ActiveX, module name is Combo.cls

Private m_ListValue() As String
Private m_RecCount As Long

Public Property Let RecCount(ByVal vData As String)
m_RecCount = vData
End Property
Public Property Get RecCount() As String
RecCount = m_RecCount
End Property

Public Property Let ListValue(Index As Integer, ByVal vData As String)
m_ListValue(Index) = vData
End Property
Public Property Get ListValue(Index As Integer) As String
ListValue(Index) = m_ListValue(Index)
End Property

Function GetValues() As String

Dim adoRs As New ADODB.Recordset
Dim i As Integer

Set adoRs = New ADODB.Recordset

adoRs.Open "Select filetype from Function", Conn, adOpenKeyset, adLockOptimistic



If Not adoRs.EOF Then
adoRs.MoveLast
adoRs.MoveFirst
m_RecCount = adoRs.RecordCount - 1
ReDim m_ListValue(adoRs.RecordCount - 1)
Do While Not adoRs.EOF
m_ListValue(i) = adoRs.Fields(0)
i = i + 1
If i > adoRs.RecordCount - 1 Then Exit Do
adoRs.MoveNext
Loop
Else
End If

Now the question, why when I call my object in the vb application it gives me the right number of records, but all the values are empty?

I try to get it like this:
dim ComboValues as new Combo

ComboValues.GetValues
For iCount = 0 To tdgbox.RecCount
cmbTDG.AddItem ComboValues.ListValue(iCount)
Next

ListValue is always empty! Why?
 
This has to wrong:
Public Property Get ListValue(Index As Integer) As String
ListValue(Index) = m_ListValue(Index)
End Property

Try

Public Property Get ListValue(Index As Integer) As String
ListValue = m_ListValue(Index)
End Property

Why As String? Why not As Long?

Public Property Let RecCount(ByVal vData As Long)
m_RecCount = vData
End Property
Public Property Get RecCount() As Long
RecCount = m_RecCount
End Property

Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Thanks, I did realized it later and it works now. But I have another question. If I call one class module from my dll to store the data and then later I want to use this data in the function in the other class module how can I do it? I tried it and the values where empty.

for example I have object.dll and there are 2 class modules

FirstObject.cls
SecondObject.cls

in FirstObject there are two parameters

m_Value1
m_Value2

if I set it through the application and then try to use it in the function which is in SecondObject the values are empty.

I do it like:

in the SecondObject

dim MyFirstObject as new FirstObject

MyFirstObject.Value1
MyFirstObject.Value2

I have no idea how to bring back these values.

Thanks
 
That is because those are two different instances of the object, each with its own properties. You'll have to pass the original instance to the object that needs the values or store your values in variables defined in a .BAS module that is inside the second class. There will be only one copy of the .BAS module variables and they will will be common across all instances (I believe) within the same process.

Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
I realize that, but how do I assign this value to the class and how do I call it after?

Thanks
 
'==========object.dll
'========= Bas Module
Public bas_Value1 As String
'==========Class 1
Public Property Get Value1() As String
Value1 = bas_value1
End Property
Public Property Let Value1(strValue As String)
bas_Value1 = strValue
End Property Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
So you mean I have to declare all my Values in bas? And there is no way of setting ID(pointer) for the instance of this cls module?
 
Sure. When you create object1 from class1 you get an object reference. In the application, you pass that object1 reference as a property or argument to a object2 instance of class2. Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
How do I capture this object reference?

P.S. Are you watching the game too?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top