Page 1 of 1
Converting from VB6 (ole/tlb/dll - Dim XXX as New YYY)
Posted: Sun Mar 08, 2009 9:44 am
by jesperbrannmark
I've been searching the forum, and not finding anything that i really can understand.
I have a VB6 codebit:
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\Windows\system32\stdole2.tlb#OLE Automation
Reference=*\G{420B2830-E718-11CF-893D-00A0C9054228}#1.0#0#C:\Windows\system32\scrrun.dll#Microsoft Scripting Runtime
Reference=*\G{D1013DBC-2B99-419D-908F-023A0C4801E3}#1.0#0#..\..\Code\pstracking\bin\Release\pstracking.tlb#pstracking
Dim cfg As New Configurator
cfg.Configuration = ConfigM
If cfg.Show(Me.hWnd) Then
ConfigM = cfg.Configuration
End If
UpdateState
I downloaded the COMate and looked at the examples. Whats really confusing me is the "Dim XXX as New YYY" which i cant translate with createobject (which is the only way in pb, or is it?)
Can someone please help?
Jesper/Sweden
Posted: Sun Mar 08, 2009 8:07 pm
by SFSxOI
You don't dim it as a new object like you did in vb6 when using comate, you just define and create the object, like this:
Code: Select all
Define.COMateObject objCfg
the you create it like this:
objCfg = COMate_CreateObject("Scripting.FileSystemObject") ; < or what ever your class/object is "Scripting.FileSystemObject" used in this example.
then after you do that you just use the methods or get the property values and stuff..
I'm not sure what your trying to do. Whats the ' Configurator' thing...a class or method or property? or something? You have a link to it in the MSDN maybe?
Posted: Sun Mar 08, 2009 10:47 pm
by jesperbrannmark
I'm really loosing hair off this
It's a .net class (i guess, i'm noob at this)
I tried to put in a PrintN(Str(objCfg)) just to see if i got any return.
objCfg = COMate_CreateObject("Scripting.FileSystemObject")
I get a return value.
objCfg = COMate_CreateObject("{AAE39A12-9009-4C81-8CAB-77688C2EF64E}")
or "ClinicBuddy.PositionSense.Configurator" i get 0.
I put a screenshots at
http://www.clinicbuddy.com/ps.jpg
I cant find Scripting in the OLE/COM object viewer - where do you get that from?
Posted: Mon Mar 09, 2009 10:21 am
by srod
If it is a .Net class then you will not be able to use it via COMate. You'd presumably need the CLR to perform all the necessary marshalling and I certainly have no experience with that kind of thing.
If you wish to access some .Net components then, to be honest, you should be using a .Net language.
Posted: Mon Mar 09, 2009 3:56 pm
by SFSxOI
jesperbrannmark wrote:I'm really loosing hair off this
It's a .net class (i guess, i'm noob at this)
I tried to put in a PrintN(Str(objCfg)) just to see if i got any return.
objCfg = COMate_CreateObject("Scripting.FileSystemObject")
I get a return value.
objCfg = COMate_CreateObject("{AAE39A12-9009-4C81-8CAB-77688C2EF64E}")
or "ClinicBuddy.PositionSense.Configurator" i get 0.
I put a screenshots at
http://www.clinicbuddy.com/ps.jpg
I cant find Scripting in the OLE/COM object viewer - where do you get that from?
For:
objCfg = COMate_CreateObject("{AAE39A12-9009-4C81-8CAB-77688C2EF64E}")
a return of 0 would not be correct I think because its not ok. But it sort of looks like you want to drill down to the Configurator 'class' (if it is a class), ClinicBuddy.PositionSense.Configurator is basically the path to the class you want to work with which looks like 'Configurator' in which case it would look like this (I think):
Code: Select all
first create object:
objClinicBuddy = COMate_CreateObject("ClinicBuddy.PositionSense.Configurator")
then we have to get the object under that:
ObjPositionSense = objClinicBuddy\GetObjectProperty("PositionSense")
then we get the object for the class we are are going to work with
objConfigurator = ObjPositionSense\GetObjectProperty("Configurator")
Now we have a 'Configurator' object we can work with and can operate with the properties and methods in the 'Configurator' (if it is a class) by using:
objConfigurator\Invoke("SomeMethod('" + variable or value here + '")")
or...
objConfigurator\Invoke("SomeMethod('" + variable or value here + '", '" + another variable or value here + "' )")
objConfigurator\GetObjectProperty("SomeObject")
objConfigurator\SetObjectProperty("SomeProperty('")
ObjBody\SetProperty("SomeProperty = '" + some_value + "'")
some_string$ = objConfigurator\GetStringProperty("SomeProperty")
some_integer.i = objConfigurator\GetIntegerProperty("SomeProperty")
Posted: Mon Mar 09, 2009 4:03 pm
by srod
A return of zero from COMate_CreateObject() means that the object could not be created!
Posted: Mon Mar 09, 2009 4:09 pm
by SFSxOI
Yep,
try it like this and see if you still get a 0:
Code: Select all
objClinicBuddy = COMate_CreateObject("ClinicBuddy.PositionSense.Configurator")