Click to See Complete Forum and Search --> : Calling/using DLLs
kittenb
Jan 29th, 2002, 08:32 AM
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:o :o and :eek:
darre1
Jan 29th, 2002, 09:08 AM
what kind of database are you trying to create?
Access?
SQL Server?
darre1
Jan 29th, 2002, 09:37 AM
can you reply to this and paste your code in your reply and i'll take a look...
kittenb
Jan 29th, 2002, 09:53 AM
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.
Edneeis
Jan 29th, 2002, 12:06 PM
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).
kittenb
Jan 30th, 2002, 04:01 AM
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.
Edneeis
Jan 30th, 2002, 10:15 AM
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.
'exposed thru props
objFromDLL1.objFromDLL2.Prop=1
'or setting to the same as the app
'if an apple obj is created by the app and is called objApple
'then the other dll exposes a class of the same kind Apple as UseApple to make them contain the same object
Set Dll2.MyApple=objApple
'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
objApple.Name="Greeny"
'or
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.
'kinda like this
apples.item("mykey").PropertyOfAnAppleClass=1
Or you could just use an If/Then behind the commandbutton and use different objects that way.
kittenb
Jan 30th, 2002, 10:39 AM
Thanks a mil. I will try this and see what happens.
kittenb
Jan 31st, 2002, 02:21 AM
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:confused: ;) :o
Wokawidget
Jan 31st, 2002, 03:50 AM
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
Public Event CreateDatabase()
Public Property SaveToTextFile(ByVal strFilename As String)
If Trim$(strFilename) = "" Then
Raiseevent CreateDatabase
Else
'Rest Of Code
End If
End Property
In your application
Private Sub Command1_Click()
1stDLL.SaveToTextFile = txtFilename.Text 'if = to "" then will fire event
End Sub
Private Sub 1stDLL_CreateDatabase()
Dim 2ndDLL As New DLL2
'Code to create database using 2ndDLL
Set 2ndDLL = Nothing
End Sub
can you see what I am getting at, or am I talkign a load of lorry drivers and jam?
Edneeis
Jan 31st, 2002, 10:27 AM
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
Public Sub SaveToFile(strFileName as string)
If trim$(strFileName)="" then
dim tmpObj as new Apple
tmpObj.SaveToTextFile strFileName
Else
dim tmpObj as New Apples
tmpObj.SaevToDB
End If
Or I will attach an example of using an object inside another object and as a collection.
Edneeis
Jan 31st, 2002, 11:57 AM
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.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.