VBA and VB6 functions return different answers?

A

Andy

I have a working set of classes and routines in Excel 2003 written in VBA.
They return the correct answers. The various functions do goal seeking and
reading and changing various cells in my spreadsheet.

I created an activex dll in VB6 and moved the code over. I included the
Excel object library and other required bits and pieces.

The problem is that the VB6 routines return into Excel a completely
different answer. One of the functions returns a double which should be
0.14426%
and instead returns 0.00028%.

All of the code moved cleanly into VB6 with the exception of routines which
acted upon Excel cells (goto cells, pasting cell values from the .dll, etc.).
All of these items take the array or cell and pass it into VBA to be dropped
into the spreadsheet.

Is a double not a double? Any pointers?

Thanks all

Andrew

I'm not even sure how to go about debugging a .dll called by Excel.
 
R

Rick Rothstein \(MVP - VB\)

It would sure be helpful to see your formula and the VBA code you came up
with to duplicate it.

Rick
 
D

Doug Glancy

Andy,

You can debug your code by adding a windows project with a Sub Main to your
dll project. In that project you can have a few lines of code that use
getobject(excel) to define the excel instance and call the dll. The
combination of the activex and windows project are called a project group.

hth,

Doug
 
P

Peter T

It sounds like one of those "something's wrong with my car, what is it" type
questions! Extremely unlikely to be some fundamental difference between VBA
/ VB6.
All of the code moved cleanly into VB6 with the exception of
routines which acted upon Excel cells (goto cells,
pasting cell values from the .dll, etc.).

Normally it's not necessary to use Activate and/or Select, if that's what
you mean by 'goto', Probably all the code can be in the dll with the vba
routine just a wrapper.
I'm not even sure how to go about debugging a .dll called by Excel.

If your VBA is calling the dll, via a reference to a public class in the
dll, you should be able to step back & forth between the two projects. In
the VB6 IDE press F5, or better still Ctrl-F5, then F8 in VBA (or place
break points in either project then F8).

Initially arrange windows so that Excel and both VBIDE's are visible and you
can see the desktop in the middle of the screen (to see and dismiss a
certain annoying message that is apt to appear).

If the dll is a com addin, put a break on any relevant entry points, with
Excel closed press Ctrl-F5, then start Excel.

In VBA Tools / references you may notice the ref switch between the .dll and
the .vbp.

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top