DUH! (Or, COM Interop – C# type consumed by VB6 program – part 5. I’m so stupid…)

You know.  Sometimes just stepping away for a few minutes can make all the difference it the world.

I closed my laptop, walked upstairs and took a shower.  All the while, in the back of my sludge pit of a brain, I was dredging around, trying to figure out how to convert the Variant that I had a hold of into a “real” EmpData.

I believe this was my train of thought… “So how do I cast ‘eData’…. Wait, I need to cast eData into something.  I need something to cast it into.  Man, if I just had an instance of EmpData defined in my VB6 program.  Hmmmm.  How would I have done this in ASP classic?  That’s right, I’d use CreateObject().  Wait.  ‘emp’ is an instance of Employee.  How did that get in there (the VB6 program)?”

It was at this time that I realized I’m a complete moron.  It was staring me in the face the whole time, just laughing at me.

The magic 2 lines of code in VB6:

    Dim eData As Employee.EmpData
    Set eData = emp.ReturnEmpData()

So simple.  I was trying to make it so hard.  Now eData is an instance of EmpData and I can DO SOMETHING WITH IT.

Forgive me…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s