[Gambas-user] [Gambas Bug Tracker] Bug #878: Possibility of having VB6-like enumerators.

bugtracker at ...3416... bugtracker at ...3416...
Mon Dec 21 19:02:55 CET 2015


http://gambaswiki.org/bugtracker/edit?object=BUG.878&from=L21haW4-

zxMarce reported a new bug.

Summary
-------

Possibility of having VB6-like enumerators.

Type             : Request
Priority         : Medium
Gambas version   : 3.8.90 (TRUNK)
Product          : Language


Description
-----------

I always miss something in Gambas that is very convenient in VB6. It can also enhance the IDE and shorten developing time.
In VB6, you can declare enumerated constants. It's just a way to "group" related-constants, and the VB6 IDE is "enum-aware".
Let's assume this code in VB6 (a screenshot is attached with the example):

  Private Enum enuExample
    ex_FirstValue = 10
    ex_SecondValue = 20
    ex_LastValue = 30
  End Enum

Then, when you DIM a variable AS enuExample, the IDE will 'autocomplete' defined values for it.

It's a very convenient way to group component/control/class property values. For example, you create a public enum in your component/control/class, and declare some property As the enum. Then, when the user wants to assign a value (for example, border types), a pop-up autocompletion menu appears with the defined values.

In VB6, these enums will only hold LONG (int32) values. VB.Net further expanded the enumerations so they can be any known type, even strings.
A real-world example would be the serial port state, which in Gambas can be Active or Inactive. Well, these values can be made as follows (values are whatever crossed my mind, they may be wrong):

  Public Enum enuSerialPortState 'a nice addition would be VB.Net's "As Integer".
    sps_PortInactive = 0
    sps_PortActive = 1
  End Enum

Then you would type:

  If myPort.Active = 

and the autocomplete list would not list every constant defined for the port (even unrelated ones), but the only two values defined for the enumeration, sps_PortInactive and sps_PortActive.

Well, that's it. It would be a real nice addition to Gambas 3.








More information about the User mailing list