I have been given source code by my boss which is written in Vb6, It runs on his machine but it gives an error on mine. The error is about declaration or I could be missing some reference.
this is the line:
Private WithEvents cP As cPopupMenu
the error is user-defined type not defined
Please advise.
Must be because you're missing the class cPopupMenu. Make sure that in your VB project the class cPopupMenu is availlable
As you said yourself, you are probably missing a reference. The project is probably referencing another activex .dll that hasn't been registered on your computer, and the cPopupMenu class resides there. Have you gone to Projects:References and looked for any references listed as Missing? They will show up there. You can also open the .vbp file in a text editor and look at the references, although going to Projects:References is generally faster and easier. Good luck!
Related
I'm pretty sure this is a bug in the VB6 IDE but I haven't found any definitive reference to it before...
Sometimes when I've loaded a project which has some dependency issue (missing reference, etc.) the IDE will show an error like this:
("Compile error: Can't find project or library")
Note the text which it highlighted is a call to the UCase$ function which is essentially built into the language. There's no way its library is actually missing.
Is this a known bug? Is there any rhyme or reason to the text which is selected when this happens?
Update: The standard libraries which include things like UCase() are included so that is not the actual problem. The highlight really seems to be nonsensical.
VB can do some strange things, but... check both the content and order of your References. UCase$() isn't 'built into the language' in the way you might think -- it's not in the VB runtime, but in the VBA runtime, which must be included as a reference.
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
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
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
Make sure all of your object types are spelled right. A simple error like spelling Variant Varient can cause this error as well.
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.
I would like VS2010 to ignore an error in XAML Code. The Reason is, it's not a real error, I have a own class of Windows and VS is not able to create an instance of it. So now it always shows "Can not create an instance of "ChildWindow"". This would not be bad, but it marks the hole file as error, and this looks realy ugly.
So: I would love to tell him to ignore the ChildWindow error, but show other errors, but don't know how.
Thanks for your advice.
EDIT:
To make the things a bit clearer here is a sample of the code:
<cis:ChildWindow ... />
.
.
.
</cis:ChildWindow>
where cis:ChildWindow is derived from UserElement. Now the preview from VS can't create an instance of childWindow and throws an errror. If I build the Project everything is fine.
Does ChildWindow create objects (or have a DataContext) that require external assemblies, hardware drivers, or anything unusually picky?
If so, and if you can find out which object this is through trial and error, sometimes the following works:
bool inDesignMode = System.ComponentModel.DesignerProperties.GetIsInDesignMode(this);
if(!inDesignMode)
InitializePickyDriver();
It's worked for me a few times.
You can right-click on the file in Solution Explorer and choose to Exclude it from the solution. You'll then be able to build your solution and it won't complain about errors in that file.
But that only works if you don't need to use the file to build your solution. If you need the file to be included then I'm not aware of any way to achieve what you want, other than commenting out the lines that are causing a problem (other than the obvious solution, which is to fix the actual problem, but I'm guessing there's a good reason you can't do that).
I'm using VB 6.0 and it gives me:
Compile Error:
Can't Find Project or Library
in this sub:
Private Sub MDITimer_Timer()
Dim textStr As String
textStr = Format(Now, "dd-mm-yyyy hh:mm:ss")
StatusBar.Panels(1).Text = textStr
End Sub
I made it like this and the error still was in the Format function (so it is not a StatusBar problem).
Can you tell me what is the Reference that we have to add to use the Format function? Or if a Reference is not needed, what do we have to do to make this work?
Problem's more likely to be the StatusBar (In the Microsoft Windows Common Controls, MSCOMCTL.ocx). Format is built into the VB6 language, you shouldn't need any reference at all.
EDIT Format is in VBA.Strings. I think this is in the "Visual Basic for Applications" reference, MSVBVM60.dll. I thought the VB6 IDE prevented you from unticking the reference.
You probably overloaded Format() with a declaration of the same name. Have you tried calling VBA.Format() instead?
You should also use Format$() to avoid the unnecessary overhead of working with the Variant result Format() returns.
I know this is old but in case someone else comes down this road...
When I had this issue found the real problem was nothing to do with MSVBVM60.dll which as said cannot be disabled as a reference.
What the error is complaining about is that a reference defined in the project is not resolved. It is not saying that the missing reference necessarily has anything to do with the function it is highlighting. What I assume the compiler is doing is sequentially searching the defined references to find the function. During that search it finds one of the references is not resolved (ie the dll or whatever is missing). This causes it to stop the search and give the error.
Reason using VBA.Format helps is that it tells the compiler where to search avoiding the need to scan through all the references.
Solution: check references defined in the project (Project => References) and make sure they are all resolved.
Usually an unresolved reference will have the word 'MISSING:' in front of it. The path shown for the reference is where the project thinks it should be, it does not mean it is there.
I have a little problem with the creation of a user control.
Though I have made a control I want to use in another control.
As soon as I want to add the reference (would like to use it as compiled OCX) in the Component's list, the message "Wechselseitiger Verweis zwischen Projekten nicht zulässig" which means something like "Circular referencing between projects is not allowed"
Strange is that the control I want to use does not have any type of reference to the first project.
I've checked this using dependency walker which is shipped as a tool with Visual Studio, but it says as well that there's no reference to the other control. I've opened the project-files using a text-editor to check for referenced OCX, I didn't find any.
To avoid some comments: change to .NET or any other language is not an option.
Comment: Why ever, adding the uncompiled .ctl-file seems to work. For now I can continue my work. But anyways I'm interested in a solution and the reason why it doesn't work with the current constellation.
VOTE FOR CLOSE: I've been looking at all the files, well and now I've just simply added all control-files to the project instead of creating OCX. I'll give it up. Thanks to all...
It is possible for VB6 to get quite confused when you add references to OCX files. You should really be adding an OCX as a component instead of using Project References.