Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / COM / October 2006



Tip: Looking for answers? Try searching our database.

Use of 'Me' in Class objects under VB6

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
canoe414@telecom-digest.zzn.com - 26 Oct 2006 10:33 GMT
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
< populate sneeze with stuff >

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
Dmitriy Antonov - 27 Oct 2006 02:56 GMT
> Greetings All,
>
[quoted text clipped - 44 lines]
>
> 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.
Dmitriy Antonov - 27 Oct 2006 05:47 GMT
>> Greetings All,
>>
[quoted text clipped - 56 lines]
>
> Dmitriy.

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

TypeName(Me)

Dmitriy.
canoe414@telecom-digest.zzn.com - 27 Oct 2006 07:32 GMT
> >> Greetings All,
> >>
[quoted text clipped - 62 lines]
>
> Dmitriy.
canoe414@telecom-digest.zzn.com - 27 Oct 2006 08:00 GMT
> 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
Dmitriy Antonov - 27 Oct 2006 15:28 GMT
>> Oops, sorry. I forgot about obvious and simple solution:
>>
[quoted text clipped - 11 lines]
>
> 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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.