Speed difference between VB and VBA

Speed difference between VB and VBA

Anonymous
Not applicable
335 Views
5 Replies
Message 1 of 6

Speed difference between VB and VBA

Anonymous
Not applicable
I have a routine I created in VBA to automate some processes that I brought
over to VB so I can compile into and EXE. The strange thing is that the VB
exe that is made takes almost 4 times the longer to do the processes VBA
does.

Granted I am not a savvy VB guru but shouldn't the same code that was in VBA
be just as fast or faster?

TIA

--
|
-+-------------------------------------------------
| Rob "in search of the elusive RR" Starz
| Stardsign cad solutions
| AEC Designer / Consultant / Developer
| Arch Desktop tools www.stardsign.com/adtcadpacx.htm
0 Likes
336 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Seems like there was a post on this just a couple days ago... to answer your
question in breif, no an executable will not be as fast as a vba macro, in
fact it can be dramatically slower. The main reason being that the
executable runs out-of-process with AutoCAD, whereas vba macros run
in-process, sharing the same memory space. If you compile into an activex
dll then you will see your speed come back.

Regards,
Jacob Dinardi


"Rob Starz" wrote in message
news:9FF12406F7883E30F77870DD66AB7195@in.WebX.maYIadrTaRb...
> I have a routine I created in VBA to automate some processes that I
brought
> over to VB so I can compile into and EXE. The strange thing is that the
VB
> exe that is made takes almost 4 times the longer to do the processes VBA
> does.
>
> Granted I am not a savvy VB guru but shouldn't the same code that was in
VBA
> be just as fast or faster?
>
> TIA
>
> --
> |
> -+-------------------------------------------------
> | Rob "in search of the elusive RR" Starz
> | Stardsign cad solutions
> | AEC Designer / Consultant / Developer
> | Arch Desktop tools www.stardsign.com/adtcadpacx.htm
>
>
0 Likes
Message 3 of 6

Anonymous
Not applicable
Once you compile to an Activex.dll how do you access the programs?

--

Dave Gardner
"Jacob Dinardi" wrote in message
news:57531F049E41C638EB5FA127AF4F5306@in.WebX.maYIadrTaRb...
> Seems like there was a post on this just a couple days ago... to answer
your
> question in breif, no an executable will not be as fast as a vba macro, in
> fact it can be dramatically slower. The main reason being that the
> executable runs out-of-process with AutoCAD, whereas vba macros run
> in-process, sharing the same memory space. If you compile into an activex
> dll then you will see your speed come back.
>
> Regards,
> Jacob Dinardi
>
>
> "Rob Starz" wrote in message
> news:9FF12406F7883E30F77870DD66AB7195@in.WebX.maYIadrTaRb...
> > I have a routine I created in VBA to automate some processes that I
> brought
> > over to VB so I can compile into and EXE. The strange thing is that the
> VB
> > exe that is made takes almost 4 times the longer to do the processes VBA
> > does.
> >
> > Granted I am not a savvy VB guru but shouldn't the same code that was in
> VBA
> > be just as fast or faster?
> >
> > TIA
> >
> > --
> > |
> > -+-------------------------------------------------
> > | Rob "in search of the elusive RR" Starz
> > | Stardsign cad solutions
> > | AEC Designer / Consultant / Developer
> > | Arch Desktop tools www.stardsign.com/adtcadpacx.htm
> >
> >
>
>
0 Likes
Message 4 of 6

Anonymous
Not applicable
set a reference to the dll in your project and it's public subs and
functions and classes become available.
tools|references
if it doesn't show up in the list means it needs to be registered with
regsvr but I didn't find that necessary, somehow it just found my dll
automatically.


David M. Gardner wrote in message
news:D0BE4B99BA8409AFBF968FB2B53BAB2E@in.WebX.maYIadrTaRb...
> Once you compile to an Activex.dll how do you access the programs?
>
> --
0 Likes
Message 5 of 6

Anonymous
Not applicable
I'm no expert, but what you are experiencing is normal. I think it has to do
with the fact that with VB, when you make calls to the AutoCAD object model
(what is referred to as Automation), this is just an inherently slower process
than making the same calls directly inside a program via VBA.

** If anybody knows otherwise, please feel free to correct me on this matter

Mark Sanchez

Rob Starz wrote:

> I have a routine I created in VBA to automate some processes that I brought
> over to VB so I can compile into and EXE. The strange thing is that the VB
> exe that is made takes almost 4 times the longer to do the processes VBA
> does.
>
> Granted I am not a savvy VB guru but shouldn't the same code that was in VBA
> be just as fast or faster?
>
> TIA
>
> --
> |
> -+-------------------------------------------------
> | Rob "in search of the elusive RR" Starz
> | Stardsign cad solutions
> | AEC Designer / Consultant / Developer
> | Arch Desktop tools www.stardsign.com/adtcadpacx.htm
0 Likes
Message 6 of 6

Anonymous
Not applicable
Your right, it's MUCH slower to work out-of-process. For virtually the same speed as vba make your project a dll with a class to recieve the autocad application from your vba project. In your vba project call the class and set the application to ThisDrawing.Application or if your only working with the active drawing you could do the same thing with that. You will be happy.
0 Likes