Click to See Complete Forum and Search --> : Duplicate definition (VB 5)


Beavis13
February 23rd, 2000, 12:11 PM
I have a problem that has been nagging me for the last week.

I have a program written in VB 5.0 (SP3) that when I compile it on my computer it works great. No errors or anything. When I take the source code down to configuration management and they try to compile it they get a "Duplicate difinition" error. As far as I know they have the same version of VB that I have and everything. When I take the source code to my other computer it works fine. When I take it to my co-workers computer it gives the same error.

I am totally confused. Help please.

Johnny101
February 23rd, 2000, 01:08 PM
Make sure you have the Option Explicit at the top of every code module. This usually means that there is variable name that is being declared twice. Also, in your VB options, under the Tools menu, be sure that you have the "Require Variable Declaration" check box checked. Doing so, should place the Option Explicit in the code modules for you.

Hope this helps,

John

John Pirkey
MCSD
www.ShallowWaterSystems.com

Beavis13
February 23rd, 2000, 01:21 PM
I have looked through the code and it doesn't have any duplicate variables. I also have option explicit at the top of every form. It is just strange how it will work on my machine but not on another.

Could it possibly be a DLL problem?

Beavis13
February 24th, 2000, 06:14 PM
Should I re-install VB on all the computers?

I am open to ALL suggestions.

Nick A.
February 25th, 2000, 02:01 AM
Strange problem....

Assuming that all the PCs you are trying this program have VB5 ServicePack 3 (and not another service pack which might be the cause of the problem), you could try a fresh installation in one PC and then try compiling the program there. If it works, there might be a problem with your PC. If it doesn't, check if there is an additional package installed to VB5 (perhaps a control or something else) on your PC that does not exist in other PCs.

Could you post the exact message? Is it just "Duplicate definition"? Doesn't it say what thing it finds duplicated?

Ravi Kiran
February 25th, 2000, 04:02 AM
Could be a problem with a little version differences in the dependencies.
If so, it can be eliminated by re-creating the project.

First printout the .vbp file (which is just a text file) . Use it as a hint

On the target machine:
Have all the source as per their directory structure, in the vbp file.
Then create a new project (on the target machine). Add all the dependencies, and then the files, and then save (same name should also be ok!).
Try compiling and check.


RK

Beavis13
February 25th, 2000, 06:24 AM
This is where it has us stumped.

All it has is a little message box with the words "Duplicate Definition" And has a "OK" and a "Help" button. If you go to help, it tells you that you might have a duplicate variable. But I have checked and I know that I don't. Plus it should not compile on my machine if I had a duplicate variable wouldn't it?

Nick A.
February 25th, 2000, 07:14 AM
Wow. Very helpful. Sometimes VB makes you so mad you wish to throw the PC out of the window..... :)

Anyway, try Ravi's suggestion and also check the code just in case you've declared a variable with an invalid name (for example: dim textbox as integer or dim webbrowser as webbrowser - Yes you can do that in VB, you don't get a compilation error). It might cause the kind of problems you describe. After that, you could start removing code from functions and try to recompile the program. You may spot the error this way but if the program is too large it may take a while... Also try to find out what's different between your PC and other PCs (in software). Different versions of libraries, patches/service packs etc. that may be related with the controls/libraries you use in your program.

Can't think of anything else. Let us know if you find anything...

Good luck.

Nick A.
February 25th, 2000, 07:16 AM
Ah, you might also try to compile the code in VB6. There is a slight chance you may get a more informative message...

Beavis13
February 28th, 2000, 11:01 AM
Monday morning update:

The problem is still here.

I made a new project and imported the forms into it. IT WORKED!! I could compile and run the program. SWEET!! But wait, don't celebrate too long. I save the file and leave for a minute. When I get back I open the project and BAM I get the "Duplicate definition" error again.

I take one of the forms out. And then put it back in. Everything works again. I save the project, close VB, restart VB, open the project, and recieve the error. This is driving me nuts.

Nick A.
February 29th, 2000, 02:00 AM
I just made a search in microsoft's site for Duplicate definition. It returned the following URL (only this one):

http://msdn.microsoft.com/library/devprods/vs6/vbasic/vbenlr98/vamsgduplicatedefn.htm

It's for VB6 but it may be your case. Check it out.