473,394 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

can i know how many item in ENUM )in run time) ?

Public Enum COLORS

RED= 0

GREEN=1

BLUD =2

ORANGE =4

End Enum
public sub FooWithColors(enmColor as COLORS )
//here , i want to able to know this in run time :
//1.many colors i have in the enum ? (4)
//2.what is the value for each color (0,1,2,4)

end sub

how can i do that in vb.net ?

thanks and have a nice day.
Jul 19 '05 #1
1 2383
Use this code (it's a console app):

Module Module1

Public Enum MyColors
RED = 0
GREEN = 1
BLUD = 2
ORANGE = 4
End Enum

Sub Main()
Dim i As Integer = [Enum].GetValues(GetType
(MyColors)).Length
Console.WriteLine("Number of values = {0}",
i.ToString)

For j As Integer = 0 To i - 1
Console.WriteLine("{0} - {1}", [Enum].GetNames
(GetType(MyColors)).GetValue(j), _
Convert.ToInt32([Enum].GetValues(GetType
(MyColors)).GetValue(j)))
Next

Console.ReadLine()
End Sub

End Module

Jeff Levinson

Author of "Building Client/Server Applications with
VB.NET: An Example Driven Approach"
-----Original Message-----
Public Enum COLORS

RED= 0

GREEN=1

BLUD =2

ORANGE =4

End Enum
public sub FooWithColors(enmColor as COLORS )
//here , i want to able to know this in run time :
//1.many colors i have in the enum ? (4)
//2.what is the value for each color (0,1,2,4)

end sub

how can i do that in vb.net ?

thanks and have a nice day.
.

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Randy Yates | last post by:
Yes, I could and have googled. Nothing outstanding came to my attention. Personal recommendations would be appreciated. -- % Randy Yates % "Maybe one day I'll feel her cold...
3
by: ThunderMusic | last post by:
Hi, When I open my MIRC, it tells me "x days xx hours xx minutes xx seconds have passed since your system last rebooted". I wanted to know if there is some way to know this information within...
3
by: Paul Janssen | last post by:
Hello! Can anyone help me out with the following situation: (a) a single query with 550 id's in the IN-clause resulting into 800+ seconds; (b) 550 queries with a single id in the IN-clause...
18
by: Visual Systems AB \(Martin Arvidsson\) | last post by:
Hi! I have created an enum list like this: enum myEnum : int { This = 2, That, NewVal = 10, LastItm
3
by: Daylor | last post by:
Public Enum COLORS RED= 0 GREEN=1 BLUD =2 ORANGE =4
13
by: toton | last post by:
Hi, I have some enum (enumeration ) defined in some namespace, not inside class. How to use the enum constant's in some other namespace without using the whole namespace. To say in little...
12
by: David Isaac | last post by:
Is it expected for access to set elements to be much slower than access to list elements? Explanation? Thanks, Alan Isaac 9.806250235714316 3.9823075279120701
1
by: mohammedss | last post by:
Hi everybody I'm a new user for mysql,i'v an application running mysql db on a linux server , now i need to check the modification time of a table and compare with a previous stored one and if...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.