Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Debugging a DLL in the VB6 IDE

Posted on 2004-04-04
9
Medium Priority
?
1,858 Views
Last Modified: 2007-12-19
Hi,

I'm creating a VBA Library DLL using VB6, and need help in using the VB6 IDE to debug the code.

I have created a new project -- ActiveX DLL -- and entered the code into a class module.

I'm having two problems:

1.  I have one class module that uses the WinAPI :

Public Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
    "GetOpenFileNameA" (pOpenFileName As OPENFILENAME) As Boolean

and I'm getting the following error:

========================================
Constants, fixed-length strings, arrays, user-defined types, and Declare statements not allowed as Public members of an object module
========================================

I  have 3 public Declare statements, and about 10 Public Const statements.  This code worked fine in the Excel VBA environment.

How do I set it up in the VB DLL project?


2.  How do I debug the DLL?

I created a test Sub to test my code, but when I press F5 the IDE acts as if it is running, but the code doesn't execute in the Sub.


My environment:
VB6 SP5
Win 2000 Pro SP3

TIA.
0
Comment
Question by:apollois
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 5

Expert Comment

by:KarcOrigin
ID: 10754267
Hi
>and I'm getting the following error:
You cannot diclare the win API in the class modules. Diclare it in the module.

To debug your Dll add a new project (Standard exe) and initiate your dll in this project. Do not forget to make it as a startup project. Press F8 to debug it.

Thx

Karc

0
 
LVL 10

Author Comment

by:apollois
ID: 10754300
Thanks for the reply Karc.

I'm new to this, so you need to give me more details please.

How do I:
1.  Initiate the DLL in the new project?
2.  Make it as a startup project?

0
 
LVL 10

Author Comment

by:apollois
ID: 10754330
Now that I have added a Standard EXE Project, and created a Project Group,  how will this affect the DLL?

When I make the DLL, does it include the EXE project?

Also, according to MS MSDN, when I create a VBA Lib DLL, I have to put all the code in  class modules.  Is it going to be a problem with the WinAPI delcare staements being in a normal module?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 5

Accepted Solution

by:
KarcOrigin earned 2000 total points
ID: 10754357
Hi,



>Make it as a startup project?

1. Open your Dll project in VB.
2. After opening it goto File menu and click on "Add project" and select the standard EXE project.
3. Now select this project on the Project plane (Generally right hand side, which shows all the project files) and right click on it.
4. You will get a popup menu. Select "Set as Startup".
Now if you press F8 the standard EXE form will appear on the screen. I think this is the answer of your second question

>Initiate the DLL in the new project?
1. Now Open the form which you have by default in your EXE project.
2. Goto Project menu and click on references
3. Select your Dll reference from the list
4. Now initiate your Dll project in the Standard EXE project -
Eg: Dim obj as new YourDll
Call the method as
obj.yourMethod()
5. Press F8 or put the break point in your dll project and press F5

I hope it will help you
Thx

0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 10754381
There is not need for a separate module, just change this:
Public Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
    "GetOpenFileNameA" (pOpenFileName As OPENFILENAME) As Boolean

To:
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
    "GetOpenFileNameA" (pOpenFileName As OPENFILENAME) As Boolean
0
 
LVL 10

Author Comment

by:apollois
ID: 10754401
acperkins,

Thanks.

What about the Const statements?

Is it better to put the Declare Function in a normal module or a class module?


Karc,

Thanks for the details -- very helpful.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 10754430
>>What about the Const statements?
Is it better to put the Declare Function in a normal module or a class module?<<
It really depends on the scope.  If they are only used in one module than IMHO there is no point in declaring them as Public in a module.
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 10756890
>>2.  How do I debug the DLL?

In order to debug your dll, you don't have to put all into 1 group. The main idea is set your dll to binary compability.

From Project menu->properites->component tab->binary compatiblility

Make sure you run your dll first before run your app from IDE
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 10788903
<ThinkingOutAloud>
   Sometimes I wonder why I even bother.
</ThinkingOutAloud>
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question