Re: VB6 compile error "constant expression required" with enum - solution
- From: Jan Hyde <StellaDrinker@xxxxxxxxxxxxxxxxxxx>
- Date: Tue, 11 Jul 2006 08:46:45 +0100
"David Carr" <David_Carr@xxxxxxxxxxxxxxxx>'s wild thoughts
were released on Mon, 10 Jul 2006 19:21:51 -0700 bearing the
following fruit:
Dredging newsgroups on Google, it would seem that this is a bug in the VB
IDE. Rather than lose your breakpoints/bookmarks, consider Jeff Ashley's
posting back on 2000.Apr.12, as it seems to do the trick:
When this happens: Put the cursor on the highlighted value, Shift f2.
On the enum line, put the cursor after 'enum', spacebar, arrow down.
(Any other edit of the line works too.) VB will insist on starting the
compile over, but you will be under way in 10 seconds or less. No need
to shut down the app!
Posting for future reference and to keep this thread around.
I've got a better way, it also solves the problem of VB
ajusting the case of you enumerations
#If 1 = 2 Then
Private Const item1 = 0
Private Const item2 = 1
Private Const item3 = 2
#End If
Private Enum enumBlahBlah
item1 = 0
item2 = 1
item3 = 2
End Enum
Since the first block of code will never be compiled you
don't have to worry about it, but it tricks VB and stops the
error your refering to from happening.
J
"David Carr" <David_Carr@xxxxxxxxxxxxxxxx> wrote in message
news:unz9Z7IpGHA.4032@xxxxxxxxxxxxxxxxxxxxxxx
In my VB6 sp6 application I have an enumeration defined:
Public Enum MyEnum
eVal1 = 0
eVal2
End Enum
And this is used in the code in a select statement:
Select Case mScenType
Case MyEnum.eVal2
All is fine and the program compiles. After some time (e.g. an hour or a
few hours) of debugging, I end up having a VB compile error "constant
expression required", where the IDE highlights the 'eVal2' part of the
Case statement above. There does not appear to be any consistency in this
behaviour. Shutting down VB6 and restarting seems to solve the problem -
unfortunate as this means losing your breakpoints and bookmarks.
Any ideas?
David
Jan Hyde (VB MVP)
--
Too many youngsters between the ages of 12 and 20 are in their
nico-teens. (Lloyd Clark)
.
- Follow-Ups:
- Re: VB6 compile error "constant expression required" with enum - solution
- From: Bob O`Bob
- Re: VB6 compile error "constant expression required" with enum - solution
- From: Robert Morley
- Re: VB6 compile error "constant expression required" with enum - solution
- References:
- VB6 compile error "constant expression required" with enum
- From: David Carr
- Re: VB6 compile error "constant expression required" with enum - solution
- From: David Carr
- VB6 compile error "constant expression required" with enum
- Prev by Date: Re: Odd VB 6.0 Bug
- Next by Date: Re: Odd VB 6.0 Bug
- Previous by thread: Re: VB6 compile error "constant expression required" with enum - solution
- Next by thread: Re: VB6 compile error "constant expression required" with enum - solution
- Index(es):
Relevant Pages
|