Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.basic.visual.misc > #860
| From | Schmidt <sss@online.de> |
|---|---|
| Newsgroups | comp.lang.basic.visual.misc |
| Subject | Re: What is a class? |
| Date | 2012-02-29 06:47 +0100 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <jike52$h28$1@speranza.aioe.org> (permalink) |
| References | (13 earlier) <jigmdl$k11$1@dont-email.me> <jigroc$q1h$1@speranza.aioe.org> <jihl1e$m6v$1@dont-email.me> <jiiiqg$q7a$1@speranza.aioe.org> <jiilag$d7r$1@dont-email.me> |
Am 28.02.2012 14:37, schrieb GS:
> I can live with the speed of my function 'as is', but for
> larger amounts of data it would be nice to use your code with a DLL.
> The wrench in the works is that this will commonly be used with VBA,
> and so is why I went with a Collection. If I had a DLL then I could
> carry it around on a memstick and use it wherever. Of course, on my
> main machine I have dhRichClient and so no need for a separate DLL.
> It's unfortunate that VBA requires external COMs be registered!
Hah - and so we finally found a good use-case for DirectCOM.dll
on your side <g>.
Please check the following out - it is using a "two-step-approach"
(sounds already complicated, but is not... ;-))
First, we have to move everything that needs speed - into
a separate VB-Dll-Project - in practise that means:
The compare-routine (without the XL-Range-stuff which
writes the results into the OutColumn - instead a vOut()
VariantArray is returned "ByRef")...
Then, only there, within this small ActiveX-Dll (which I named
MyWrapper.dll, having only a small Class, named: cMyClass),
there's a reference to dhSortedDictionary (the smaller,
a bit faster version of the RC-based cSortedDictionary).
Within this new VB6-Dll we now only need to ensure, that
the externally referenced Class (cSortedDictionary
from dhSortedDictionary.dll) is created regfree per
DirectCOM (one normal Dll-Declare - one Call with the
correct Path and we're done).
That's it already on the VB6-end (the VB6-Code for
MyWrapper.dll is included in the Zip).
So now we have an ActiveX-Dll, which creates its
external Helper (cSortedDictionary) already regfree
and also contains the fast Compare-Routine, which
we now were able to compile even to native code.
Now XL comes into play - which will work only with
your new Wrapper cMyClass and will not know anything
about any sorting Dictionaries - these are already
"encapsulated out of the way".
So what remains is (to complete the regfree-hierarchy,
and my above mentioned "two steps"), to create your
cMyClass regfree also in XL ... *and* latebound (As Object),
so that XL not even knows (and gets confused by) the
Interface-Reference of your cMyWrapper.dll.
Here's the DirectCOM related code-part which ensures
the regfree Loading/Instancing:
'*** In a VBA-Module
Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" _
(ByVal lpLibFileName As String) As Long
Declare Function GetInstance Lib "DirectCom" Alias "GETINSTANCE" _
(FName As String, ClassName As String) As Object
Function CreateWrapperInstanceRegFree(ByVal WorkBookPath As String)
Static hLib As Long
If Right$(WorkBookPath, 1) <> "\" Then WorkBookPath = WorkBookPath & "\"
'preload DirectCOM.Dll (only once) into the Excel-Process
If hLib = 0 Then hLib = LoadLibrary(WorkBookPath & "DirectCOM.dll")
Set CreateWrapperInstanceRegFree = GetInstance(WorkBookPath & _
"MyWrapper.dll", "cMyClass")
End Function
And this is the hollowed out Original VBA-Function, which
now delegates the main-task to your Wrapper-Class:
Function FilterMatches2&(vFilterRng(), vCheckRng(), _
OutColumnName As String, _
Optional ByVal Mode As FilterMode, _
Optional ByVal DupesAllowed As Boolean, _
Optional ByVal TypeComparison As ExpectedTypes)
Dim Wrp As Object, vOut()
'this instantiates cMyClass (a VB6-Compiled Wrapper)
Set Wrp = CreateWrapperInstanceRegFree(Application.ActiveWorkbook.Path)
FilterMatches2=Wrp.FilterMatches2(vFilterRng,vCheckRng,vOut, Mode, _
DupesAllowed, TypeComparison)
Columns(OutColumnName).ClearContents
If FilterMatches2 > 0 Then
With Range(OutColumnName & "1").Resize(FilterMatches2, 1)
.Value = vOut
.NumberFormat = "0000000000000" '..optional
.EntireColumn.AutoFit '..optional
End With
End If
End Function
Please check it out - here's a complete example
including a MatchTest.xls with a 50000er test-set.
www.datenhaus.de/Downloads/XLRegFreeCOM.zip
Olaf
Back to comp.lang.basic.visual.misc | Previous | Next — Previous in thread | Next in thread | Find similar
What is a class? Peter Nolan <peter.nolan40@gmail.com> - 2012-02-24 04:02 -0800
Re: What is a class? "Auric__" <not.my.real@email.address> - 2012-02-24 14:06 +0000
Re: What is a class? Peter Nolan <peter.nolan40@gmail.com> - 2012-02-25 03:07 -0800
Re: What is a class? Helmut_Meukel <Helmut_Meukel@bn-hof.invalid> - 2012-02-25 14:19 +0100
Re: What is a class? "Auric__" <not.my.real@email.address> - 2012-02-25 21:26 +0000
Re: What is a class? Jim Mack <no-uce-ube@mdxi.com> - 2012-02-25 18:58 -0500
Re: What is a class? GS <gs@somewhere.net> - 2012-02-25 19:39 -0500
Re: What is a class? "Auric__" <not.my.real@email.address> - 2012-02-26 03:09 +0000
Re: What is a class? Jim Mack <no-uce-ube@mdxi.com> - 2012-02-25 22:35 -0500
Re: What is a class? GS <gs@somewhere.net> - 2012-02-25 22:55 -0500
Re: What is a class? "Farnsworth" <nospam@nospam.com> - 2012-02-25 23:27 -0500
Re: What is a class? GS <gs@somewhere.net> - 2012-02-26 01:30 -0500
Re: What is a class? "Auric__" <not.my.real@email.address> - 2012-02-26 04:41 +0000
Re: What is a class? ralph <nt_consulting64@yahoo.net> - 2012-02-25 23:05 -0600
Re: What is a class? "Henning" <computer_hero@coldmail.com> - 2012-02-26 11:24 +0100
Re: What is a class? ralph <nt_consulting64@yahoo.net> - 2012-02-25 23:03 -0600
Re: What is a class? GS <gs@somewhere.net> - 2012-02-26 01:26 -0500
Re: What is a class? "Stuart McCall" <smccall@myunrealbox.com> - 2012-02-27 04:15 +0000
Re: What is a class? ralph <nt_consulting64@yahoo.net> - 2012-02-27 00:48 -0600
Re: What is a class? "Mayayana" <mayayana@invalid.nospam> - 2012-02-27 08:57 -0500
Re: What is a class? "Stuart McCall" <smccall@myunrealbox.com> - 2012-02-27 19:19 +0000
Re: What is a class? "Stuart McCall" <smccall@myunrealbox.com> - 2012-02-27 19:12 +0000
Re: What is a class? "Bob Butler" <bob_butler@cox.invalid> - 2012-02-27 06:06 -0800
Re: What is a class? "Stuart McCall" <smccall@myunrealbox.com> - 2012-02-27 19:24 +0000
Re: What is a class? GS <gs@somewhere.net> - 2012-02-27 11:01 -0500
Re: What is a class? ralph <nt_consulting64@yahoo.net> - 2012-02-27 11:07 -0600
Re: What is a class? GS <gs@somewhere.net> - 2012-02-27 13:10 -0500
Re: What is a class? Schmidt <sss@online.de> - 2012-02-27 19:09 +0100
Re: What is a class? GS <gs@somewhere.net> - 2012-02-27 13:29 -0500
Re: What is a class? GS <gs@somewhere.net> - 2012-02-27 14:43 -0500
Re: What is a class? Schmidt <sss@online.de> - 2012-02-27 22:14 +0100
Re: What is a class? GS <gs@somewhere.net> - 2012-02-27 16:45 -0500
Re: What is a class? GS <gs@somewhere.net> - 2012-02-27 18:23 -0500
Re: What is a class? GS <gs@somewhere.net> - 2012-02-27 23:26 -0500
Re: What is a class? Schmidt <sss@online.de> - 2012-02-28 13:54 +0100
Re: What is a class? GS <gs@somewhere.net> - 2012-02-28 08:37 -0500
Re: What is a class? ralph <nt_consulting64@yahoo.net> - 2012-02-28 09:19 -0600
Re: What is a class? GS <gs@somewhere.net> - 2012-02-28 10:42 -0500
Re: What is a class? Schmidt <sss@online.de> - 2012-02-29 06:47 +0100
Re: What is a class? GS <gs@somewhere.net> - 2012-02-29 09:39 -0500
Re: What is a class? GS <gs@somewhere.net> - 2012-02-29 13:33 -0500
Re: What is a class? GS <gs@somewhere.net> - 2012-02-29 14:43 -0500
Re: What is a class? Schmidt <sss@online.de> - 2012-02-29 21:39 +0100
Re: What is a class? GS <gs@somewhere.net> - 2012-02-29 16:15 -0500
Re: What is a class? Schmidt <sss@online.de> - 2012-02-29 23:20 +0100
Re: What is a class? GS <gs@somewhere.net> - 2012-02-28 00:16 -0500
Re: What is a class? Jim Mack <no-uce-ube@mdxi.com> - 2012-02-27 13:26 -0500
Re: What is a class? "Stuart McCall" <smccall@myunrealbox.com> - 2012-02-27 19:33 +0000
Re: What is a class? Jim Mack <no-uce-ube@mdxi.com> - 2012-02-27 15:50 -0500
Re: What is a class? Helmut_Meukel <Helmut_Meukel@bn-hof.invalid> - 2012-02-26 11:02 +0100
Re: What is a class? GS <gs@somewhere.net> - 2012-02-26 14:23 -0500
Re: What is a class? GS <gs@somewhere.net> - 2012-02-26 17:09 -0500
Re: What is a class? ralph <nt_consulting64@yahoo.net> - 2012-02-25 22:21 -0600
Re: What is a class? "Auric__" <not.my.real@email.address> - 2012-02-26 04:51 +0000
Re: What is a class? ralph <nt_consulting64@yahoo.net> - 2012-02-25 23:10 -0600
Re: What is a class? Peter Nolan <peter.nolan40@gmail.com> - 2012-02-26 04:11 -0800
Re: What is a class? Helmut_Meukel <Helmut_Meukel@bn-hof.invalid> - 2012-02-26 16:37 +0100
Re: What is a class? "Auric__" <not.my.real@email.address> - 2012-02-26 18:36 +0000
Re: What is a class? ralph <nt_consulting64@yahoo.net> - 2012-02-26 14:11 -0600
Re: What is a class? Peter Nolan <peter.nolan40@gmail.com> - 2012-02-27 03:11 -0800
Re: What is a class? "Auric__" <not.my.real@email.address> - 2012-02-27 16:33 +0000
Re: What is a class? Jim Mack <no-uce-ube@mdxi.com> - 2012-02-27 13:33 -0500
Re: What is a class? Peter Nolan <peter.nolan40@gmail.com> - 2012-02-28 04:07 -0800
Re: What is a class? Peter Nolan <peter.nolan40@gmail.com> - 2012-02-25 03:33 -0800
Re: What is a class? Peter Nolan <peter.nolan40@gmail.com> - 2012-02-25 04:19 -0800
Re: What is a class? "Ivar" <ivar.ekstromer000@ntlworld.com> - 2012-02-24 15:15 +0000
Re: What is a class? GS <gs@somewhere.net> - 2012-02-24 14:52 -0500
Re: What is a class? "Ivar" <ivar.ekstromer000@ntlworld.com> - 2012-02-24 23:10 +0000
Re: What is a class? GS <gs@somewhere.net> - 2012-02-24 19:46 -0500
Re: What is a class Way off Topic "Ivar" <ivar.ekstromer000@ntlworld.com> - 2012-02-25 02:20 +0000
Re: What is a class Way off Topic GS <gs@somewhere.net> - 2012-02-25 16:57 -0500
Re: What is a class? Helmut_Meukel <Helmut_Meukel@bn-hof.invalid> - 2012-02-25 11:36 +0100
Re: What is a class? Peter Nolan <peter.nolan40@gmail.com> - 2012-02-25 03:35 -0800
Re: What is a class? Jim Mack <no-uce-ube@mdxi.com> - 2012-02-24 15:23 -0500
Re: What is a class? "Auric__" <not.my.real@email.address> - 2012-02-25 01:33 +0000
Re: What is a class? Peter Nolan <peter.nolan40@gmail.com> - 2012-02-25 03:09 -0800
Re: What is a class? "Mayayana" <mayayana@invalid.nospam> - 2012-02-24 20:05 -0500
csiph-web