473,804 Members | 3,305 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(e nmColor 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 2418
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(GetT ype
(MyColors)).Len gth
Console.WriteLi ne("Number of values = {0}",
i.ToString)

For j As Integer = 0 To i - 1
Console.WriteLi ne("{0} - {1}", [Enum].GetNames
(GetType(MyColo rs)).GetValue(j ), _
Convert.ToInt32 ([Enum].GetValues(GetT ype
(MyColors)).Get Value(j)))
Next

Console.ReadLin e()
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(e nmColor 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
1063
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 embrace, %% Fuquay-Varina, NC % and kiss her interface, %%% 919-577-9882 % til then, I'll leave her alone." %%%% <yates@ieee.org> % 'Yours Truly, 2095', *Time*, ELO...
3
1241
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 .NET. Thanks ThunderMusic
3
2270
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 resulting into overall time of <60 seconds; The table consists of 950.000 records, and the resultset consists of 205.000 records.
18
11375
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
266
by: Daylor | last post by:
Public Enum COLORS RED= 0 GREEN=1 BLUD =2 ORANGE =4
13
18164
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 detail, the enum is declared as, namespace test{ enum MyEnum{ VALUE1,VALUE2 };
12
1932
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
1640
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 it's newer it will run a script to delete some rows from it . I wrote it with the help of a friend but i can't reach him now. I tried the " show table status update_time " but i could not use it well So can any one help me in this. This is...
0
9708
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10588
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10085
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5662
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3827
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.