473,396 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

NewEnum diffeculties

I have used the Class Builder in my vb6 project to create a collection class
for my project. Using Class Builder automatically create the NewEnum method
for you, and I've done this a hundred time, and everything is good. So, I
have a CFiles class that contains a collection of CFile objects. I added a
method to the CFiles object, GetPatternFiles, which returns a CFiles object.
The point of this is for my CFiles object to return a subset of CFile
objects, in the returned CFiles collection. I search the existing mCol
variable to see if each individual CFile object meets a certain criteria,
and if so, .Add it to the "subset" CFiles object.

in class CFiles
'-----------------------------------------------------------------------------------------
Public Function GetPatternFiles(sPattern As String) As CFiles
'-- This variable will be used in the For...Each to search my existing
mCol variable
Dim oMyFile As CFile

'-- We will return a new subsetted CFiles collection from ourselves
Dim oMyReturnFiles As CFiles

'--
Dim oMyNewFile As CFile

For Each oMyFile In mCol
If oMyFile.ContainsPattern(sPattern) = True Then
'-- Create a new "subset" CFiles collection to return to caller
If oMyReturnFiles Is Nothing Then
Set oMyReturnFiles = New CFiles
End If
Set oMyNewFile = oMyReturnFiles.Add(oMyFile.Path)
End If
Next

Set GetPatternFiles = oMyReturnFiles

Set oMyReturnFiles = Nothing

End Function
'-----------------------------------------------------------------------------------------

Seemingly, all this works, now comes the exception of the NewEnum method of
the CFiles collections.
When the caller of m_oOriginalCFilesObject.GetPatternFiles("test") gets the
returned CFiles collection, I cannot do a For...Each using that CFiles
object

In specific a

'-- The new CFiles object that will be a subset of the existing CFiles
object
Dim oMyFiles As CFiles

'-- Used in the For ... Each
Dim oMyFile As CFile

Dim ListItemX As ListItem

'-- m_oPatterns is a collection of oPattern objects, which has a String
".Pattern" property
For Each oPattern In m_oPatterns
Set oMyFiles = m_oMyFiles.GetPatternFiles(oPattern.Pattern)
For Each oMyFile In oMyFiles
Set ListItemX = lvwFilesA.ListItems.Add(, , oPattern.Pattern)
ListItemX.SubItems(1) = oMyFile.Path
Next
Next

VB6 gags on the
For Each oMyFile in oMyFiles with an
Run-time error '438':
Object doesn't support this property or method error

Why can't I use the NewEnum method with my returned "subset" collection
class ?
Any ideas/opinions ?

Mike
Oct 24 '05 #1
2 10081

"Mike" <mb*******@SPAMskypoint.com> wrote in message
news:UP********************@skypoint.com...
I have used the Class Builder in my vb6 project to create a collection class
for my project. Using Class Builder automatically create the NewEnum method for
you, and I've done this a hundred time, and everything is good.
(big snip)

Why can't I use the NewEnum method with my returned "subset" collection class
?
Any ideas/opinions ?


I will bet $1 that you can't use any For Each ... iterator with your CFiles
class, whether the one returned by GetPatternFiles or otherwise.

While Class Builder does setup the NewEnum for you, it is easy to loose the
required setting. It doesn't copy/paste, for instance.

Assuming you already have

Public Property Get NewEnum() As IUnknown
'this property allows you to enumerate
'this collection with the For...Each syntax
Set NewEnum = mCol.[_NewEnum]
End Property

Click on the word NewEnum, then click on menu Tools, Procedure Attributes...
Make sure NewEnum is the selected method, then click the Advanced button on the
form.
My $1 bet is that the Procedure ID is not -4. If you make it so, and click OK,
you should be able to use For Each.

Oct 25 '05 #2
Steve,
That was the problem. I'm astonded at that. I have used the Class Builder
many times, and I have made my own collection classes many times. In making
my own, I've put in my own NewEnum, with the (-4) business. I have never
noticed before that the Class Builder would garble that stuff up. I checked
the 2 other collection classes that this project uses, and the NewEnum has
the (-4). I wonder if putting in the new method (GetPatternFiles) somehow
messed things up. Anyway, it works now, thanks for stating the obvious. I
would have spent more time, thrasing around, not even thinking to make sure
that Procedure Attribute setting was *still* correct.

Mike

"Steve Gerrard" <my********@comcast.net> wrote in message
news:fP********************@comcast.com...

"Mike" <mb*******@SPAMskypoint.com> wrote in message
news:UP********************@skypoint.com...
I have used the Class Builder in my vb6 project to create a collection
class for my project. Using Class Builder automatically create the NewEnum
method for you, and I've done this a hundred time, and everything is good.


(big snip)

Why can't I use the NewEnum method with my returned "subset" collection
class ?
Any ideas/opinions ?


I will bet $1 that you can't use any For Each ... iterator with your
CFiles class, whether the one returned by GetPatternFiles or otherwise.

While Class Builder does setup the NewEnum for you, it is easy to loose
the required setting. It doesn't copy/paste, for instance.

Assuming you already have

Public Property Get NewEnum() As IUnknown
'this property allows you to enumerate
'this collection with the For...Each syntax
Set NewEnum = mCol.[_NewEnum]
End Property

Click on the word NewEnum, then click on menu Tools, Procedure
Attributes...
Make sure NewEnum is the selected method, then click the Advanced button
on the form.
My $1 bet is that the Procedure ID is not -4. If you make it so, and click
OK, you should be able to use For Each.

Oct 25 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Remco Groot Beumer | last post by:
Hello, Someone asked me if it would be possible to write (in VB or VB.NET) a program that helps users in a Terminal Server environment to set a default printer for themselves. I do not have very...
9
by: tiger79 | last post by:
Hi, I've been translating some API's from VB to C# for a couple of days now. Only I'm a real newbie to both languages, but I managed to do most of it except the next statements, so if anyone knows...
8
by: Charles | last post by:
I do not understand why I am getting a "Specified cast is not valid" error, since it has worked before. Something has changed and I am not really sure what it could be. I am looking for something...
8
by: t | last post by:
In VB6, I usually use objptr function and API copymemory to identify and obtain an object, how can I convert them into VB2005? Your kindly help would be much appreciated.
9
by: YYZ | last post by:
After reading many messages in this group, it seems that the preferred setting for this is ON. Okay, I did that in my project (first with ..Net -- long time VB6 developer) and now a bunch of...
9
by: Terry | last post by:
I am converting (attempting) some vb6 code that makes vast use of interfaces. One of the major uses is to be able to split out Read-only access to an obect. Let me give you a simple (contrived)...
7
by: The Doctor | last post by:
A rather elementary question, In VB5, how can I pass a variable from one form to another?
3
by: MariuszC | last post by:
Hello, I have used some library where is defined enum like: typedef enum Enum1 { ENUM1_1, ENUM1_2, ENUM1_3, ENUM1_4, ENUM1_5 }; In my code I have defined: typedef enum Enum2 { ENUM2_1,...
5
by: pinkfloydfan | last post by:
Hi there I have the following situation...I want to perform an operation on an Enum parameter but I don't know which one of a number of Enums it will be on. The function would include...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.