msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Use of 'Me' in Class objects under VB6

 
Post new topic   Reply to topic    msvisual.com Forum Index -> OLE Automation
Author Message
canoe414



Joined: 04 Oct 2007
Posts: 28

PostPosted: Thu Oct 26, 2006 6:33 am    Post subject: Use of 'Me' in Class objects under VB6 Reply with quote

Greetings All,

I built a Collection Class named musicColl using the VB Class Wizard
then manually added the following

Public Sub Dumpout()
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Dim pwd As String
pwd = CurDir()
Dim fullfilename As String
fullfilename = pwd & "\" & "sneeze_dump.txt" ' <----
here
Dim txtstream8 As TextStream
Set txtstream8 = fso.OpenTextFile(fullfilename, ForWriting, True)
Dim elem As keyarry
For Each elem In mCol
fulline = elem.kkey & " = " & Join(elem.arry)
txtstream8.WriteLine (fulline)
Next
txtstream8.Close
End Sub
-----------------------

Then in my main code----------

Dim sneeze As musicColl
Set sneeze = New musicColl


sneeze.Dumpout
-----------------------------------------

I'll soon have many Collections of class musicColl.
I'd like to have the subroutine Dumpout() "know" the name of it's own
instance
(in this case "sneeze") so it will create output files with appropriate
names ie.

sneeze.Dumpout => sneeze_dump.txt
froth.Dumpout => froth_dump.txt

How should I go about accomplishing this? Some permutation of the "Me"
term?

TIA,

Steve

Archived from group: microsoft>public>vb>ole>automation
Back to top
View user's profile Send private message
Dmitriy Antonov



Joined: 04 Oct 2007
Posts: 431

PostPosted: Fri Oct 27, 2006 1:56 am    Post subject: Re: Use of 'Me' in Class objects under VB6 Reply with quote

wrote in message @m73g2000cwd.googlegroups.com...
> Greetings All,
>
> I built a Collection Class named musicColl using the VB Class Wizard
> then manually added the following
>
> Public Sub Dumpout()
> Dim fso As Object
> Set fso = CreateObject("Scripting.FileSystemObject")
> Dim pwd As String
> pwd = CurDir()
> Dim fullfilename As String
> fullfilename = pwd & "\" & "sneeze_dump.txt" ' <----
> here
> Dim txtstream8 As TextStream
> Set txtstream8 = fso.OpenTextFile(fullfilename, ForWriting, True)
> Dim elem As keyarry
> For Each elem In mCol
> fulline = elem.kkey & " = " & Join(elem.arry)
> txtstream8.WriteLine (fulline)
> Next
> txtstream8.Close
> End Sub
> -----------------------
>
> Then in my main code----------
>
> Dim sneeze As musicColl
> Set sneeze = New musicColl
>
>
> sneeze.Dumpout
> -----------------------------------------
>
> I'll soon have many Collections of class musicColl.
> I'd like to have the subroutine Dumpout() "know" the name of it's own
> instance
> (in this case "sneeze") so it will create output files with appropriate
> names ie.
>
> sneeze.Dumpout => sneeze_dump.txt
> froth.Dumpout => froth_dump.txt
>
> How should I go about accomplishing this? Some permutation of the "Me"
> term?
>
> TIA,
>
> Steve
>

You have to name it yourself. For example, you can create private similarly
named string constants in each class and assign them a name. Or you can
create read-only property (e.g. Name), where you can return hard-coded name
(or return constant mentioned before). Main point - there is nothing ready -
you must do it.

For public classes there is, possibly, a way by using one of techniques,
which read type lib info, but I don't think this complication is of lesser
"weight" then the one above.

Dmitriy.
Back to top
View user's profile Send private message
Dmitriy Antonov



Joined: 04 Oct 2007
Posts: 431

PostPosted: Fri Oct 27, 2006 4:47 am    Post subject: Re: Use of 'Me' in Class objects under VB6 Reply with quote

"Dmitriy Antonov" wrote in message %23GHA.1224@TK2MSFTNGP05.phx.gbl...
>
> wrote in message
> @m73g2000cwd.googlegroups.com...
>> Greetings All,
>>
>> I built a Collection Class named musicColl using the VB Class Wizard
>> then manually added the following
>>
>> Public Sub Dumpout()
>> Dim fso As Object
>> Set fso = CreateObject("Scripting.FileSystemObject")
>> Dim pwd As String
>> pwd = CurDir()
>> Dim fullfilename As String
>> fullfilename = pwd & "\" & "sneeze_dump.txt" ' <----
>> here
>> Dim txtstream8 As TextStream
>> Set txtstream8 = fso.OpenTextFile(fullfilename, ForWriting, True)
>> Dim elem As keyarry
>> For Each elem In mCol
>> fulline = elem.kkey & " = " & Join(elem.arry)
>> txtstream8.WriteLine (fulline)
>> Next
>> txtstream8.Close
>> End Sub
>> -----------------------
>>
>> Then in my main code----------
>>
>> Dim sneeze As musicColl
>> Set sneeze = New musicColl
>>
>>
>> sneeze.Dumpout
>> -----------------------------------------
>>
>> I'll soon have many Collections of class musicColl.
>> I'd like to have the subroutine Dumpout() "know" the name of it's own
>> instance
>> (in this case "sneeze") so it will create output files with appropriate
>> names ie.
>>
>> sneeze.Dumpout => sneeze_dump.txt
>> froth.Dumpout => froth_dump.txt
>>
>> How should I go about accomplishing this? Some permutation of the "Me"
>> term?
>>
>> TIA,
>>
>> Steve
>>
>
> You have to name it yourself. For example, you can create private
> similarly named string constants in each class and assign them a name. Or
> you can create read-only property (e.g. Name), where you can return
> hard-coded name (or return constant mentioned before). Main point - there
> is nothing ready - you must do it.
>
> For public classes there is, possibly, a way by using one of techniques,
> which read type lib info, but I don't think this complication is of lesser
> "weight" then the one above.
>
> Dmitriy.
>

Oops, sorry. I forgot about obvious and simple solution:

TypeName(Me)

Dmitriy.
Back to top
View user's profile Send private message
canoe414



Joined: 04 Oct 2007
Posts: 28

PostPosted: Fri Oct 27, 2006 3:32 am    Post subject: Re: Use of 'Me' in Class objects under VB6 Reply with quote

Dmitriy Antonov wrote:
> "Dmitriy Antonov" wrote in message
> %23GHA.1224@TK2MSFTNGP05.phx.gbl...
> >
> > wrote in message
> > @m73g2000cwd.googlegroups.com...
> >> Greetings All,
> >>
> >> I built a Collection Class named musicColl using the VB Class Wizard
> >> then manually added the following
> >>
> >> Public Sub Dumpout()
> >> Dim fso As Object
> >> Set fso = CreateObject("Scripting.FileSystemObject")
> >> Dim pwd As String
> >> pwd = CurDir()
> >> Dim fullfilename As String
> >> fullfilename = pwd & "\" & "sneeze_dump.txt" ' <----
> >> here
> >> Dim txtstream8 As TextStream
> >> Set txtstream8 = fso.OpenTextFile(fullfilename, ForWriting, True)
> >> Dim elem As keyarry
> >> For Each elem In mCol
> >> fulline = elem.kkey & " = " & Join(elem.arry)
> >> txtstream8.WriteLine (fulline)
> >> Next
> >> txtstream8.Close
> >> End Sub
> >> -----------------------
> >>
> >> Then in my main code----------
> >>
> >> Dim sneeze As musicColl
> >> Set sneeze = New musicColl
> >>
> >>
> >> sneeze.Dumpout
> >> -----------------------------------------
> >>
> >> I'll soon have many Collections of class musicColl.
> >> I'd like to have the subroutine Dumpout() "know" the name of it's own
> >> instance
> >> (in this case "sneeze") so it will create output files with appropriate
> >> names ie.
> >>
> >> sneeze.Dumpout => sneeze_dump.txt
> >> froth.Dumpout => froth_dump.txt
> >>
> >> How should I go about accomplishing this? Some permutation of the "Me"
> >> term?
> >>
> >> TIA,
> >>
> >> Steve
> >>
> >
> > You have to name it yourself. For example, you can create private
> > similarly named string constants in each class and assign them a name. Or
> > you can create read-only property (e.g. Name), where you can return
> > hard-coded name (or return constant mentioned before). Main point - there
> > is nothing ready - you must do it.
> >
> > For public classes there is, possibly, a way by using one of techniques,
> > which read type lib info, but I don't think this complication is of lesser
> > "weight" then the one above.
> >
> > Dmitriy.
> >
>
> Oops, sorry. I forgot about obvious and simple solution:
>
> TypeName(Me)
>
> Dmitriy.
Back to top
View user's profile Send private message
canoe414



Joined: 04 Oct 2007
Posts: 28

PostPosted: Fri Oct 27, 2006 4:00 am    Post subject: Re: Use of 'Me' in Class objects under VB6 Reply with quote

> Oops, sorry. I forgot about obvious and simple solution:
>
> TypeName(Me)

I see how this will return the name of the class which makes up an
instance of the object.
But I need the inverse - something that will tell me the name of the
instance from within the object.

I can see how to do it manually, I figured there must be an easier way
for an instance of an object to reference itself.

Thx,

Steve
Back to top
View user's profile Send private message
Dmitriy Antonov



Joined: 04 Oct 2007
Posts: 431

PostPosted: Fri Oct 27, 2006 2:28 pm    Post subject: Re: Use of 'Me' in Class objects under VB6 Reply with quote

wrote in message @m7g2000cwm.googlegroups.com...
>> Oops, sorry. I forgot about obvious and simple solution:
>>
>> TypeName(Me)
>
> I see how this will return the name of the class which makes up an
> instance of the object.
> But I need the inverse - something that will tell me the name of the
> instance from within the object.
>
> I can see how to do it manually, I figured there must be an easier way
> for an instance of an object to reference itself.
>
> Thx,
>
> Steve
>

In this case you must do it yourself. There is no such thing as an "instance
name". The name of variable, which currently holds an object, is not a good
candidate and even if so, it doesn't exist at run time - it is just an
address in a compiled executable.

Dmitriy.

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Viewing Multiple OLE Objects Working in Access 2002 along with Word 2002. We have many OLE objects in our database, all Word files, and contained within the OLE object are multiple more OLE objects, all embedded. As an example, we have a multiple-page Word document, but each page wit

feeding table with ole objects Hi I am trying to feed a table (open as a recordset) with existing ole objects, but it doesn't seem to work. Does anybody have a hint for me? (kind of sample code) thanks in advance! Vladimir

OLE to Store Outlook EMail Objects in Access I've created a form with an OLE obect linked to a MS Access OLE Object. I need to store an email from Outlook in the field. Everything works fine if I drop the email on my desktop and then pick it up and drop it onto OLE object in the VB form. If I drag

How to recognize the Class in a BoundObjectFrame I'm using a table to store different OLE-Objects. In a i could see all objects right. But i can't get the class property in VB. This Item is empty or the OLE-object is unvailable.

Error 430 - Class does not support Automation or does not su Hello Everyone, I'm having an issue with a .NET COM Interop Assembly within VB 6. When I try to create a new instance of a class, in VB 6.0, I receive the following error: "Error 430 - Class does not support Automation or does not support the expected in
Post new topic   Reply to topic    msvisual.com Forum Index -> OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group