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

Cant create an instance of a class...

Status
Not open for further replies.

elziko

Programmer
Nov 7, 2000
486
0
0
GB
I have an object model that looks like this in the VB6 Class Wizard:

UDLObjectModel.gif

I'm trying to create instances of my clsDataNumeric value class like so:

Me.NumerData.Item(i).NumericValues.Add

All the code seems to run fine but when I do something like:

ATest.SomeNumericItems.SomeNumericValues.Count I get 0 and the object above was never created.

What I'm really getting at is:

Is there any problem of having a collection class with a collection class type of thing? Why cant I create an unstance of this class?

How come my clsNumericItem is listed twice in the VB6 Class Wizard (see above image)?

I know I can't post my code because its far to complex but any advice would be good.

Cheers

elziko
 
Post the code for your add method. Is it returning an object? Is it raising an error? -Chris Didion
Matrix Automation, MCP
 
I have hardly changed the code that the wizard created for me:

Public Function Add(Key As String, EngineeringUnits As String, MaxCaptureValue As Long, Units As String, EngineeringName As String) As clsNumericItem
'create a new object
Dim objNewMember As clsNumericItem
Set objNewMember = New clsNumericItem


'set the properties passed into the method
objNewMember.Key = Key
objNewMember.EngineeringUnits = EngineeringUnits
objNewMember.MaxCaptureValue = MaxCaptureValue
objNewMember.Units = Units
objNewMember.EngineeringName = EngineeringName

mCol.Add objNewMember

'return the object created
Set Add = objNewMember
Set objNewMember = Nothing


End Function


No errors are raised. I can create instances of all the other classes I have just fine!

Cheers

elziko
 
WilMead,

nah! The code itself is very simple! Would you like me to post the code for all nine classes??? LOL LOL
 
mCol.Add objNewMember

This statement is inside your public function Add, but I can't find any reference to mCol.
I suppose this is your Collection? Has it somewhere been declared Public? If not, it should be passes as an additional parameter _________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
Also your function Add has the same name as the Collection Class' method Add. Doesn't that introduce some ambiguity into the code? Which Add does the statement mCol.Add objNewMember have to use? _________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top