Link to home
Start Free TrialLog in
Avatar of rbsubra
rbsubra

asked on

How to declare a Variable of type User Defined Type available in a Active X DLL without referecing the dll in a VB Projects?

How to declare a Variable of type User Defined Type available in a Active X DLL without referecing the dll in a VB Projects?

Plz. Help
Avatar of AzraSound
AzraSound
Flag of United States of America image

there be some magic i'm missing but how do you plan to access any property, method, and/or event of an activex dll w/o first referencing it in your project?

if this is just a UDT you want then you can declare the same UDT in your project - you dont need an activex dll to do that.  just copy and paste

Private Type myDLL_UDT
    Item1 As Long
    Item2 As String
    etc...
End Type
Avatar of rbsubra
rbsubra

ASKER

Hi,

  I want to declare it from active x dll, and pass it back to the dll to do some process. Is the idea what u have given will work? i don't want redeclare it again!!!!! One place should be enough for that ? why should we have to declare at two places? i don't like the code reduntancy


i think you worded your question wrong...you said you wanted access to a UDT w/o referencing your dll...do you mean you just want to have a UDT in a dll that you can pass back and forth between a client program and the dll?
Avatar of rbsubra

ASKER

Yes.
Your Correct.
Thanks for Correcting me.
Have u got any method to do this kind of operation
ok this is how you could do it:

in your class in the activex dll -

Public Type myType
    str As String
End Type

Private m_udt As myType

Public Property Let UDT(New_UDT As myType)
    m_udt = New_UDT
End Property

Public Property Get UDT() As myType
    UDT = m_udt
End Property

Private Sub Class_Initialize()
    m_udt.str = "Hello"
End Sub




on your test form that calls the dll -


Dim myDLL As DLL.Class1

Private Sub Command1_Click()
    Dim var As Variant
    var = myDLL.UDT
    MsgBox var.Str
    var.Str = "Goodbye"
    MsgBox var.Str
End Sub

Private Sub Form_Load()
    Set myDLL = New DLL.Class1
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set myDLL = Nothing
End Sub
Avatar of rbsubra

ASKER

Yes. Its working......i have used createobject to implement the same.
You have got the credits for your performance

Thanks Friend
With Love
If you have a UDT defined in a publicly accessible class module of your ActiveX DLL and it is declared as public, your main app can just declare a variable of that type.

ActiveX DLL Class:
Public Type udtTest
  x1 as long
  x2 as integer
  x3 as string
End Type

Standard EXE w/ reference to above DLL:
private TestThatUDT as udtTest

I have tested this it it works perfectly (without the need of properties).
You don't have to use variants either!!!
very happy i could help  :-)
ok if that works
Hi AzraSound, looks like everyone forgot this one.  Since you provided the solution, you should lock it down.
ASKER CERTIFIED SOLUTION
Avatar of AzraSound
AzraSound
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Force accepting Azrasound's comment.

costello
Community Support Moderator @ Experts-Exchange