Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 "Constant Expression Required" Error on Enumeration 1

Status
Not open for further replies.

jamesste

Programmer
Apr 12, 2007
1
US
I have a solution to an old thread (thread710-62825) in case someone is still having this trouble like I was.

The original post was:
---------------------------------------------------------
Galford (Programmer)

I have the following enumeration defined in a class:

'Class module to handle connection to database
Public Enum DBLoc
DBLocal = 1
DBServer = 2
End Enum

From time to time, I'll get a compile error stating Constant Expression Required even though it is defined in the class.

Is this a bug or did I do something wrong? Any help would be appreciated.

Thanks
---------------------------------------------------------

This turned out to be a bug in VB, and I had to search around a bit to get this answer.

1. Put the cursor on the highlighted value
2. Type Shift - f2.
3. On the enum line, put the cursor after 'enum'
4. Type spacebar and then arrow down.

You will have to restart the compile, but it will work again after that.

Thanks to "David Carr" <David_Carr@NoSpamCanada.Com> for providing the answer.

If anyone has a better or more permanent solution for this bug, please let us all know.

Thanks
 

What I usually do is just cut it the enum block and move down a line or two and paste it back in. Works most of the time, but not always. I'll see if your solution works better, though it will take a while, as it may go a few weeks with no problems, and then several times on one day.
 
I've found that restarting the IDE always works.
 
I just had the problem again, and tried the solution posted by jamesste and it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top