|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Get Const. NameHi,
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? > In other words, can I have a reverse mapping of a constant value and its Yes you can. You can get list of all constants using Reflection. Then > corresponding constant name? 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/microsoft.public.dotnet.languages.csharp/browse_frm/thread/a73d6b81389ddd4e/248a6ddb220e5aff http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_frm/thread/2b0317041399ef13/edc41ad1d52c4d04 for more info. -- Peter Macej Helixoft - http://www.vbdocman.com VBdocman - Automatic generator of technical documentation for VB, VB ..NET and ASP .NET code "Amjad" <Am***@discussions.microsoft.com> schrieb: Use an enumeration type (keyword 'Enum').> 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)? -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
The old Structure/Class Argument
Migrating From ListBox to ListView: Only One Problem DATE HELLLPPPP RTF How to make Windows inaccessible from my software user? Help ClickOnce Deployment questions BindingSource for a class - need a light bulb moment newbie question vb.net bits Change the write path for My.Application.Log.WriteEntry? |
|||||||||||||||||||||||