Results 1 to 12 of 12

Thread: Calling/using DLLs

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Posts
    11

    Red face Calling/using DLLs

    I have a form and 2 dlls which the form is referencing. Is it possible for me to access 1 of the dlls via the other dll? When I click my run button on the form, I want to run the first dll which will allow the user to store the results to a txt file. If the user does not want to save results to a txt I need to call the other dll which is made up of several classes. One of the classes has a method to create a mdb using dao and that is the cls that I would like to access but I cannot.

    Say dll one is called me and one of the cls in dll 2 is called apple and another apples. I want to access apple via apples. Is this possible? So when I click cmdRun on the form depending on what the user chooses will call either dll. The mdb will be created on-the-fly when its method is called. I would appreciate your help. If there is another way to do this, please tell me because I am about to go and

  2. #2
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    what kind of database are you trying to create?

    Access?
    SQL Server?
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  3. #3
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    can you reply to this and paste your code in your reply and i'll take a look...
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Posts
    11

    code

    I am sorry, there is not point in doing that I was hoping that you could have given me some idea from my question. Thanks for your time.

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    One of the classes has a method to create a mdb using dao and that is the cls that I would like to access but I cannot.
    Why not?

    Is apples a collection of apple?

    Did you make these DLLs?

    I guess I am not sure exactly what you are trying to accomplish or what the problem is (I can be slow sometimes).

  6. #6

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Posts
    11
    Thank you for responding E. Yes, I created the dlls. apple is to import/export exporting single apple

    apples Provides the handling of mulitiple apples, primarily for the purposes of importing certain data.

  7. #7
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I have a form and 2 dlls which the form is referencing. Is it possible for me to access 1 of the dlls via the other dll?
    Yes you can add a reference to the other dll in the first dll and have it access it either internally or it could expose it through properties and such. You could also have it pass in an object from the 2nd dll and have the app use SET to set a reference to the same instance of any object from dll 2 that the app is using.

    VB Code:
    1. 'exposed thru props
    2. objFromDLL1.objFromDLL2.Prop=1
    3.  
    4. 'or setting to the same as the app
    5. 'if an apple obj is created by the app and is called objApple
    6. 'then the other dll exposes a class of the same kind Apple as UseApple to make them contain the same object
    7. Set Dll2.MyApple=objApple
    8. 'now DLL2.MyApple contains a reference to objApple from the app so the following would now be doing the same thing on the same obj
    9. objApple.Name="Greeny"
    10. 'or
    11. DLL2.MyApple.Name="Greeny"

    Say dll one is called me and one of the cls in dll 2 is called apple and another apples. I want to access apple via apples. Is this possible? So when I click cmdRun on the form depending on what the user chooses will call either dll. The mdb will be created on-the-fly when its method is called.
    If apples is a collection of apple then this is very easy. You would simply use the item property of the collection to access the objects contained therein.

    VB Code:
    1. 'kinda like this
    2. apples.item("mykey").PropertyOfAnAppleClass=1

    Or you could just use an If/Then behind the commandbutton and use different objects that way.

  8. #8

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Posts
    11
    Thanks a mil. I will try this and see what happens.

  9. #9

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Posts
    11
    Just one min there Bro Ed, I want to access the function,subs,procedures in Apple because when I created the dll with the apple, apples and other cls and do myDLL. I only got apples hanging off it (myDLL.Apples) and the functs in apples but none of the funct in apple. Are you saying that I should do something like dim Apple as new Apple in the Apples or Apple class? Where do I do the declaration? Please show me an eg sub for the particular cls and how to call the sub from my main form that is referencing the dll. I kinda got the idea of what you said yesturday but I am not getting it clearly. Please be patient, I am only a newbie. Thanky

  10. #10
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Talking When will it all end?...Oh, in 2 hours!...Cheers.

    Not sure if I read your question correctly as I am having a day which can only be described as a hedgehog playing in a liquidiser.

    In your 1st DLL you could have events, which when "fired" could be used to execute somesort of function/event in the 2nd DLL. ie



    Inside 1st DLL
    VB Code:
    1. Public Event CreateDatabase()
    2.  
    3. Public Property SaveToTextFile(ByVal strFilename As String)
    4.    If Trim$(strFilename) = "" Then
    5.       Raiseevent CreateDatabase
    6.    Else
    7.       'Rest Of Code
    8.    End If
    9. End Property

    In your application
    VB Code:
    1. Private Sub Command1_Click()
    2.    1stDLL.SaveToTextFile = txtFilename.Text 'if = to "" then will fire event
    3. End Sub
    4.  
    5. Private Sub 1stDLL_CreateDatabase()
    6. Dim 2ndDLL   As New DLL2
    7.    'Code to create database using 2ndDLL
    8.    Set 2ndDLL = Nothing
    9. End Sub

    can you see what I am getting at, or am I talkign a load of lorry drivers and jam?

  11. #11
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Well it depends a lot on what Apple cls does compared to Apples are they almost the same?

    Wokawidget's suggestion will work, you could also do it outside of your objects. Like in the SaveToFile sub
    VB Code:
    1. Public Sub SaveToFile(strFileName as string)
    2.    If trim$(strFileName)="" then
    3.       dim tmpObj as new Apple
    4.       tmpObj.SaveToTextFile strFileName
    5.    Else
    6.      dim tmpObj as New Apples
    7.      tmpObj.SaevToDB
    8.    End If

    Or I will attach an example of using an object inside another object and as a collection.

  12. #12
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Here is that example I said I'd give although it is VERY poor, considering I'm not sure what any of the functionality is in your project.

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