CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2001
    Location
    Israel
    Posts
    228

    annoying name changing

    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!
    ----------

  2. #2
    Join Date
    Aug 2001
    Location
    New York, USA
    Posts
    169

    Re: annoying name changing

    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
    .
    .
    .





    [email protected]

  3. #3
    Join Date
    Jun 2001
    Location
    Israel
    Posts
    228

    Re: annoying name changing

    yes, ofcourse but that is the whole idea of Enum, creating a union of consts...

    ----------
    The @host is everywhere!
    ----------

  4. #4
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: annoying name changing

    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

  5. #5
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: annoying name changing

    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.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  6. #6
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: annoying name changing

    I tried out my example on VB 5.0 (no service pack ) and it fails for me also.

    John G

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured