[RESOLVED] Project Refence Issue With MID$ Function
You've got to forgive me. I'm supporting an application written in VB6 and I'm not familiar with how VB6 works (I usually work with .NET).
Anyway, I have some source code that compiles into a .DLL and have opened the project file and when I compile the thing, I get a "Compile error: Can't find project or library" error and it highlights the MID$ code. When I click on OK, it prompts me with the references window. So which reference am I missing? Do I need to update my VB6 or something?
I'm truly a newbie and haven't touched VB6 in years so your help (and not laughter) is greatly appreciated....
Thanks in advance.
And is there a way to just compile it without running it?
You should a reference to VBA in your project.
You should also have a reference to VBA objects and procedures and a reference to VBA runtime objects and procedures
Actually the problem is likely to be that "something" is missing from your references, not anything in particular.
In the references list you probably have an item ticked which starts with "MISSING: ", and that is the problem. You need to replace this item with a working version - but how you do that depends on what it is (it may be something you have another version of, or it may not be installed on your system).
And is there a way to just compile it without running it?
Nope, and there would be no point - if it doesnt work when you are compiling, it wont work later.
I don't see anything in my available references that is called "VBA..." but I do see something called "Visual Basic for Applications" and in fact, one of them is already checked, but when I scroll down the list, I see another 5 items on the list with the same name, "Visual Basic For Applications". Could it be that I have the wrong one checked? Should I just go ahead and check them all?
As far as the "Missing" idea goes, you are right. There is one referenced called "MISSING: Microsoft CDO for NTS 1.2 Library". So if this reference is in fact missing, how do I go about installing it and refreshing the reference? Could ths CDONTS 1.2 library be causing my MID$ compilation error?
I don't see anything in my available references that is called "VBA..." but I do see something called "Visual Basic for Applications" and in fact, one of them is already checked, but when I scroll down the list, I see another 5 items on the list with the same name, "Visual Basic For Applications". Could it be that I have the wrong one checked? Should I just go ahead and check them all?
As far as the "Missing" idea goes, you are right. There is one referenced called "MISSING: Microsoft CDO for NTS 1.2 Library". So if this reference is in fact missing, how do I go about installing it and refreshing the reference? Could ths CDONTS 1.2 library be causing my MID$ compilation error?
Thanks for helping out this newbie.
About Mid$. Try using VBA.MID$ in your code. Sometimes VB gets confused.
The VBA.MID$ works. Now I can do a global search and replace, but instead (and I know I'm being picky), is there a reference that could be updated or something so I don't do it? Apparently it worked for the previous developer (she didn't need the VBA.MID$).
Press F2 in the IDE to bring up the Object Browser. Then Type MID$ in the search box (the lower of the two dropdowns) and click the binoculars. Does it find more than one library that contains the MID$? BTW to my embarrassment kids in high school called me Smarty Marty.
Like I mentioned above, after I did a global search & replace of MID$ to VBA.MID$, now it won't compile because of the Chr functions. It like VBA.Chr, but not Chr by itself. Do you think it's a reference thing? I'd hate to go through the whole thing and add VBA. to all the functions. Yowzah
As far as the "Missing" idea goes, you are right. There is one referenced called "MISSING: Microsoft CDO for NTS 1.2 Library". So if this reference is in fact missing, how do I go about installing it and refreshing the reference? Could ths CDONTS 1.2 library be causing my MID$ compilation error?
It would be - there have been several similar cases before (with different Missing items, but the effect is the same).
From a support article on microsoft.com (here), it seems that you need to have Exchange (Server or Administrator) or Outlook Web Access (for Exchange 5.5) installed - they will provide the required files for you.
Like I mentioned above, after I did a global search & replace of MID$ to VBA.MID$, now it won't compile because of the Chr functions. It like VBA.Chr, but not Chr by itself. Do you think it's a reference thing? I'd hate to go through the whole thing and add VBA. to all the functions. Yowzah
What items are currently selected in your References?
Visual Basic For Applications
Visual Basic runtime objects and procedures
Visual Basic objects and procedures
OLE Automation
Microsoft ActiveX Data Objects 2.5 Library
Microsoft Scripting Runtime
Microsoft Script Control 1.0
Crystal Reports 8.5 ActiveX Designer Run Time Library
Microsoft VBScript Regular Expressions 5.5
Microsoft XML, version 2.0
MISSING: Microsoft CDO for NTS 1.2 Library
Microsoft Word 11.0 Object Library
The Visual Basic For Applications is located: C:\WINDOWS\System32\msvbvm60.dll
When I scroll down the list under Available References, I find 5 "Visual Basic For Applications" options that are unchecked and I don't know if I have the wrong version checked. Why is there more than one? 3 of the unchecked options reference .OLB files, one of them references msvbcm50.dll. The other one has a location path that is longer than what the box is displaying. So I don't know what it is referencing...
The first 4 that you show are the ones that are selected by default. The Visual Basic For Applications that is checked should be the one that refers to msvbvm60. I assume that msvbvm50 is associated with VB5 and this one with VB6. Can you eliminate any of the others? Are you using XML, scripting, Crystal Reports and Word, etc. all in the same project?
So I have the project installed on my local machine and I don't think installing Exchange or OWA for Exchange is an option. Is there any other options for getting CDONTS installed?
After copying the VBP file somewhere else (in case things go wrong), you can try to fix the references. You will probably need to select a new item in the references list (as it is a different version). Once you have done that you can remove the old reference.
I think I got it to work. I copied the CDONTS.dll file from the test server to my local box and put it under the c:\windows\system32 folder and it compiled! Thank you to both of you for helping this newbie out.