"Date" giving compiler error "Can't find project or library" (VB6)

knocte picture knocte · Nov 29, 2013 · Viewed 8.2k times · Source

I have some VB6 code that I need to port to VB.NET or C# or F#.

First of all, I try to compile it, and it doesn't succeed. When I press F5, a dialog box is opened that tells me "Can't find project or library" while highlighting the word "Date" in the following if condition:

Dim HourAux As Date
...
If (HourAux > CDate (Date & " " & Question(2).Text) Then
...
End if

So, what I'm wondering is:

  1. Have I been given code that really doesn't compile and needs to be fixed?
  2. Or am I missing something really obvious like a reference to a library or something?
  3. Or is it that I'm trying to compile VB5 code with a VisualStudio (6.0) that is for VB6?

Thanks in advance for any comments or help.

Answer

knocte picture knocte · Jan 5, 2014

So it turns out I was simply missing a reference that my project requires, and VisualStudio (or the VB compiler) is giving a very misleading error.

I was missing the reference "Microsoft Excel 8.0 Object Library", and to get it I had to install Microsoft Office, obviously. You find the references of your project by going to the menu Project -> References... in VS main menu.