Click to See Complete Forum and Search --> : annoying name changing
deghost
August 10th, 2001, 04:23 PM
Hi,
i have a problem: i've created a Public Enum in a module and declared some variables of this type, my problem is that whenever i want to set/check the variable for the Enum value name it changes it's letters (in the Enum declaration)
i.e. if i wrote: Public Enum... MyConst=3...
and later i write: if MyVar=myconst, MyConst turns to myconst.
how can i override that?
----------
The @host is everywhere!
----------
enigmaos
August 10th, 2001, 05:56 PM
you can declare it as a PUBLIC CONST seperately instead of declaring it in that Public Enum function.
public Const MyConst = 3
.
.
.
public Enum... MyConst...
.
.
.
If MyVar = MyConst then
.
.
.
enigmaos@yahoo.com
deghost
August 12th, 2001, 01:57 PM
yes, ofcourse but that is the whole idea of Enum, creating a union of consts...
----------
The @host is everywhere!
----------
John G Duffy
August 13th, 2001, 08:43 AM
Tried a little test case and could not duplicate your described error. I am using VB 6.0 Pro edition. Here is the sample I used.
'
' In a module
'
option Explicit
public Enum MyConstants
MyConst = 1
End Enum
'
'
In a form
'
option Explicit
private Sub Text1_Change()
Text1 = MyConst
End Sub
I keyed the Text1 = myconst and VB IDE changed it to MyConst just like it is spelled in the Enum not viceversa as you specified. Look for another usage of the myconst in your program that could be effecting the outcome.
John G
Clearcode
August 13th, 2001, 08:58 AM
No - I get the behaviour described in VB5(SP2)
It may have been fixed in VB6.
I developed a peculiar coding style as a result:
'usual code
Select Case EventVB.WindowMessage
Case WM_MOVE
Case else
End Select
'workaround thingy
Select Case true
Case EventVB.WindowMessage = WM_MOVE
Case else
End Select
That way the IDE always provides you with a dropdown of the enumerated type options so you don't get the chance of changing their case.
HTH,
Duncan
-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
John G Duffy
August 13th, 2001, 02:22 PM
I tried out my example on VB 5.0 (no service pack ) and it fails for me also.
John G
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.