Suman George
Suman George

Reputation: 49

Get Constant name from value in VB6

I have defined some Global Constants:

'Reason Codes'
 Global Const MQRC_NONE = 0
 Global Const MQRC_APPL_FIRST = 900
 Global Const MQRC_APPL_LAST = 999

Now I want to get the constant name from its value in VB6.

Is it possible, I know it can be done in .Net and Java. Not sure about vb6.

Upvotes: 0

Views: 382

Answers (1)

Mahmoud Fayez
Mahmoud Fayez

Reputation: 3459

Use a select statement. I do not like this solution but at least you can get things done with it.

    Select Case constantValue
            Case MQRC_NONE 
                 result = "MQRC_NONE"
            Case MQRC_APPL_FIRST
                 result = "MQRC_APPL_FIRST"
            Case MQRC_APPL_LAST
                 result = "MQRC_APPL_LAST"
            Case Else
                 result = "N/A"
    End Select

If you have control over the constant values make them range 0,1,2. Then you can just index another array of equivalent constant strings based on this constant index.

Upvotes: 1

Related Questions