6
votes

I have some vb6 code I have not compiled in a long time. The last compile is in production. Now I get an error "User-defined type is not defined" when I do a full compile. I'm sure there is a reference missing. But there is no code that is hi-lighted. And I cannot seem to find what reference might be lost.

Any clues as to what I can do to find the missing reference would be very helpful.

Thanks!

Dave

4
Have you tried Option Explicit OnShahzeb
could you paste your variable definitions for us? That would help in identifying the necessary references needed (if any)ZnArK
This is a project with about 250 forms, classes, and modules. It would be great if I could narrow down the code to post just area that is a problem. But there is no way to do that. And, yes, option explicit is set to on everywhere.Dave Kearney
Try using find /I "Dim " * This will give you all the variable declarations. Sort out the unique ones and start eliminating from there. Do you have a "last known good" configuration to compare any changes against?ZnArK
OK... I understand what you're asking but not sure how to do a find /I. I know the vb6 find dialog... how do I type a command? The immediate window returns an error. Thanks for your help!Dave Kearney

4 Answers

4
votes

I've had that happen before it drove me crazy!! But then I found this:

  http://support.microsoft.com/kb/190197  

Occurs when compiling with binary compatibility on. The above solution suggests turning off binary compatibility and re-compiling - then missing reference will then be highlighted.

Other steps you can try:

  • Rather than turning off BC for everything look for ones that have been recently changed
  • search C: drive and dev folder and delete any *.oca files
  • also look in the vbp file for any oca references
3
votes

You need to ensure that you have the appropriate items checked in the References dialog. This is outside the code and they are listed in the VBP file (text file).

EDIT Corrected reference storage. Thanks MarkJ

0
votes

Make sure all of your object types are spelled right. A simple error like spelling Variant Varient can cause this error as well.

0
votes

Are you still using the same machine in which the original compile was made and / or with the same OS ?

If the answer is no, then there is a chance that VB6 or its like linked to a reference which is no longer available in Win7 or later, this may also include the compiler if you are using a modern version of studio.

Since the code is also in VB6, if you are using any outside commercial controls, and again if not on the same machine, you would loose those links as well if you did not port over the library.