Post

 Resources 

Console

Nitro for VB


Using it with VB



Create a new VB project and add a button to it. From the menu, choose project->references and pick our component:

Image


Press OK and you are ready to use the library in our sample VB project. Within the button-code add the following code:

  1. Dim oMyObject As New MyObject  
  2.   
  3. MsgBox Format(oMyObject.Calculate(2, 5000000))  


Now we are ready with this tutorial. Try the Sample (check the link at the button). In the sample, I have implemented the same functionality in VC++ and in VB. Compare the speed of both version. But try it more than once, because our VC is loaded for the first time into memory. This will cause our first execution a littlebit slower. Remember, that this calculation is pretty uncomplex. You can get a lot more out of it.

I hope this tutorial will help you develope VC++ COM-objects for VB. If you have any question about using other data-types than "long", ask me or take a look at msdn online or the VC++ online manual (OLE types).

Tip - Debugging our component with VC++
How can I debug this object if it is used from VB? This is easy: Make an executeable (project1.exe) from your VB project. In VC++ set the compile option from "Win 32 - Release MinSize" to "Win 32 - Debug".

Image


Specify the VB project.exe as executeable for the debug session and set a breakpoint in your code. Now press "F5" to "run" your component. After that the VB application is started and if you reach the breakpoint the VC++ debugger will stop at the C++ code. That's it.

Download the source: You can download the source of the tutorial here.


| 1 | 2 | 3 | 4 | 5

1 comment

Tutorial Console

Tutorial by:

Torsten Damberg


Date: 2000 May 11


Navigate



1 comment

Latest comment


by: Soulmartyr

I'm not sure about anyone else, but in VB 2005 Express Edition, things seem to run just as fast as VC++ when you compile them and run the stand-alone.

Is anyone else seeing this? I made two different .DLL libraries, one in VB2k5, one in VC++. The method in the libraries did a calculation of the SIN(30) *2 in a for-next loop for five-thousand repitions. I saw an average difference of .0000002 seconds in running the two different versions. I used QueryPerformanceCounter to time everything.

Post a Comment


Printer Friendly



Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.
There have been 42 visitors within the last 20 minutes
RSS News Feed