Results 1 to 4 of 4

Thread: String Constants in ActiveX Projects

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2003
    Location
    India
    Posts
    7

    Question String Constants in ActiveX Projects

    Can anybody tell me how could one expose string constants from an ActiveX DLL Projects. The reason I want to do this is that some File name or Table name that are frequently used through the ActiveX DLL should be available to the user (or the client app).

    One way to do this is through Read-Only Property in a Global Multiuse class. But this is not the right way of implementing this. So the only option is to declare the String Constant in one of the Standard Modules and Expose them through the Type Library.

    But the problem is HOW DO I EXPOSE THE STANDARD MODULES FROM AN ACTIVEX DLL OR EXE

    Only Hard-core programmers would be able to answer this quesion and I am sure one is out there.

    There are lots and lots of other such quieries which requires an indepth knowledge of programming in VB, but I want to start with this one.

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    VB Code:
    1. ' Module:
    2. Public g_strYourVariable As String
    3.  
    4. ' User control:
    5. Public Property Get YourVariable() As String
    6.     YourVariable = g_strYourVariable
    7. End Property
    8.  
    9. Public Property Let YourVariable(ByVal strVar As String)
    10.     g_strYourVariable = strVar
    11. End Property

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2003
    Location
    India
    Posts
    7

    axion_sa did not understood the problem

    Go through the posted message thoroughly, it seems you did not understand what's the requirement.

    Explanation of the above problem with an example .....

    Everybody must have used vbCrLf to introduce a line feed in the string to be displayed.

    Where does this vbCrLf come from, obviously from one of the 3 VB standard library. I don't remember at present but it is defined in VBA. Where ever it may it is easy to find through the object browser. Find it and you will notice that it comming from a Standard Module and not from a Class.

    What axion_sa has mentioned is a Public String Property that is available only through the object of that particular class. He is correct if the requirement is that you want a public string property for an object.

    But here what I want is that the string should not be part of any object (i.e., class) but should be avialable Globally like vbCrLf is avialable globally.

    For this one needs a Standard module to be exposed from the ActiveX project. But the Standard module is public only within the ActiveX project and not out side. So how could one expose Standard modules from an ActiveX project. If one could do that he/she can expose a public string constant from the ActiveX project to other client app.

  4. #4
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    The correct way to do this would be to declare the constant in a Public Module,
    however VB doesn't allow you to create such an animal, leaving you only with the option of creating a Global MultiUse Class Module and use Read-Only properties.
    (as you've already discovered.

    This is simply a limitation of VB, if you really need to create these constants in the correct way,
    use Visual C to create the DLL instead.

    Personally, I think using a Global MultiUse class module is a sufficient work-around as it gives you the functionality you require.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width