Valhalla Legends Forums Archive | Visual Basic Programming | Passing user defined type in object module event

AuthorMessageTime
UserLoser
I have an event, i.e.:

[code]
Public Event OnClanMemberInformation(ByVal Cookie As Long, ByVal Status As Byte, ByVal ClanName As String, ByVal Rank As Byte, ByVal DateJoined As Variant)
[/code]

Now I want DateJoined to be a filetime, but obviously you cannot do that.  In my handler:

[code]
Private Sub RecvClanMemberInformation()
    Dim Cookie As Long
    Dim Status As Byte, Rank As Byte
    Dim ClanName As String
    Dim DateJoined As FileTime
    'Get cookie
    Cookie = ParseBuffer.NextDword
    'Get status
    Status = ParseBuffer.NextByte
    'If status equals zero, user is not in a clan
    If (Status <> 0) Then
        'Get clan name
        ClanName = ParseBuffer.NextString
        'Get rank
        Rank = ParseBuffer.NextByte
        'Get date joined filetime
        DateJoined.LowDateTime = ParseBuffer.NextDword
        DateJoined.HighDateTime = ParseBuffer.NextDword
    End If
    'Throw event
    RaiseEvent OnClanMemberInformation(Cookie, Status, ClanName, Rank, DateJoined)
End Sub
[/code]

What's the best way to go about raising an event including a filetime? I have variant there in the event declaration only so it will compile...I suppose I could make a filetime class but that seems kinda stupid...maybe maybe not
July 3, 2006, 5:53 PM
LoRd
In the past, I've always just passed a pointer to the structure.
July 3, 2006, 5:58 PM
UserLoser
[quote author=Lord[nK] link=topic=15330.msg155272#msg155272 date=1151949515]
In the past, I've always just passed a pointer to the structure.
[/quote]

Hmm, that'd work but I think it'd be too messy for what my goal is in the long run.  Thanks, but since my only UDT I'm dealing with is a filetime, I'm just going to create a filetime class.  Thought of some nifty ideas for it too
July 3, 2006, 6:01 PM
Ringo
Use a public object module, rather than a private one, then just pass the udt byref?
Or if you want to keep it a private object, then I would do as lord said, and pass the position of the variable in memory with VarPtr() or somthing.
July 3, 2006, 6:17 PM
TheMinistered
The only way to have a public object module, is to locate your class inside an ActiveX DLL project.  However, there are two ways to pass this:

1) Their way via VarPtr, which is quite dirty and ugly
2) Use the FRIEND modifier on the function you wish to pass the FILETIME struct, and of course you must pass byref!

Sigh, do I have to explain VB SYNTAX too? n00bs! :)
July 13, 2006, 9:21 PM
Ringo
[quote author=TheMinistered link=topic=15330.msg155675#msg155675 date=1152825718]
The only way to have a public object module, is to locate your class inside an ActiveX DLL project. 
[/quote]
My bad, alot of my projects these days are ActiveX exe's, rather than standard ones, where public objects are not an issue.
What i ment by "If you want to keep it as a private object", was so people cant referance the exe and use the class.

Cool @ the Friend modifier, I didnt know about that :P
July 14, 2006, 4:38 AM
TheMinistered
I don't really understand why most of your projects are activex executables... you only need activex exes for certain things... but i'm sure you have valid reasoning... hmm ;p
July 17, 2006, 3:05 PM

Search