PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft VB .NET
Get Const. Name
Forums
Newsgroups
Microsoft DotNet
Microsoft VB .NET
Get Const. Name
![]() |
Get Const. Name |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi,
I have a module that contains a large list of Constants (e.g. Const alert1 as Integer = 123), and I have a function that returns an "alert" number as integer (e.g. 123). Is there a way to present to the user the name of that constant returned by the function according to the constants list (e.g. "alert1"), instead of just presenting a numeric value returned (e.g. 123)? In other words, can I have a reverse mapping of a constant value and its corresponding constant name? |
|
|
|
#2 |
|
Guest
Posts: n/a
|
> In other words, can I have a reverse mapping of a constant value and its
> corresponding constant name? Yes you can. You can get list of all constants using Reflection. Then you just loop all constants and find the one which has the specified value. Then you can get its name. See http://groups.google.com/group/micr...48a6ddb220e5aff http://groups.google.com/group/micr...dc41ad1d52c4d04 for more info. -- Peter Macej Helixoft - http://www.vbdocman.com VBdocman - Automatic generator of technical documentation for VB, VB ..NET and ASP .NET code |
|
|
|
#3 |
|
Guest
Posts: n/a
|
"Amjad" <Amjad@discussions.microsoft.com> schrieb:
> I have a module that contains a large list of Constants (e.g. Const alert1 > as Integer = 123), and I have a function that returns an "alert" number as > integer (e.g. 123). Is there a way to present to the user the name of that > constant returned by the function according to the constants list (e.g. > "alert1"), instead of just presenting a numeric value returned (e.g. 123)? Use an enumeration type (keyword 'Enum'). -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

