473,326 Members | 2,124 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,326 software developers and data experts.

enumeration help

Can someone explain, or point me to a good link that explains enumerations
for a newbie.

Thats
Jun 8 '06 #1
4 1094
I always think of enumerations as a logical grouping of numerical constants.
A bonus of enumerations is that you can assign multiple values to a single
variable.

enum fileaccess
faReadLock =0
faWriteLock=1
faReadShare=2
faWriteShareRead=4
faWriteShareWrite = 8
end enum

dim pintFileAccess as fileaccess = fileaccess.faWriteShareRead and
fileaccess.faWriteShareWrite

when you look at the properties of a control in the designer, many times you
will notice use of enumerations. Windows.WindowsState is an enumeration

FormWindowState.Normal = 0,
FormWindowState.Minimized = 1 ,
FormWindowState.Maximized = 2

Enumerations reduce ambiguity

"Jason" <so*****@microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Can someone explain, or point me to a good link that explains enumerations
for a newbie.

Thats

Jun 8 '06 #2
Hello AMDRIT,

The code you propose below will give pintFileAccess a value of faReadLock
(0). I believe you were trying to give it a value that would express both
the faWriteShareRead and faWriteShareWrite values (12). You would produce
this value by using a bitwise OR instead of an AND.

Dim pintFileAccess As FileAccess = FileAccess.faWriteShareRead OR FileAccess.faWriteShareWrite

-Boo
I always think of enumerations as a logical grouping of numerical
constants. A bonus of enumerations is that you can assign multiple
values to a single variable.

enum fileaccess
faReadLock =0
faWriteLock=1
faReadShare=2
faWriteShareRead=4
faWriteShareWrite = 8
end enum
dim pintFileAccess as fileaccess = fileaccess.faWriteShareRead and
fileaccess.faWriteShareWrite

when you look at the properties of a control in the designer, many
times you will notice use of enumerations. Windows.WindowsState is an
enumeration

FormWindowState.Normal = 0,
FormWindowState.Minimized = 1 ,
FormWindowState.Maximized = 2
Enumerations reduce ambiguity

"Jason" <so*****@microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Can someone explain, or point me to a good link that explains
enumerations for a newbie.

Thats

Jun 8 '06 #3
AMDRIT wrote:
enum fileaccess
faReadLock =0
faWriteLock=1
faReadShare=2
faWriteShareRead=4
faWriteShareWrite = 8
end enum

dim pintFileAccess as fileaccess = fileaccess.faWriteShareRead and
fileaccess.faWriteShareWrite
The assignment above does /not/ do what you want:
Dim pintFileAccess As fileaccess _
= fileaccess.faWriteShareRead And fileaccess.faWriteShareWrite


this works out to

pintFileAccess = 2 And 8
= 0 !!

I think you meant to say

Dim pintFileAccess as fileaccess _
= fileaccess.faWriteShareRead Or fileaccess.faWriteShareWrite

Also, if you're going to do this sort of "bit-wise" combination, you
should add the Flags() attribute to your Enumeration.

Contrast ...

Enum FileAccess
.. . .
Dim a As FileAccess _
= FileAccess.faWriteShareRead Or FileAccess.faReadShare
? a.ToString()
12

.... with ...

<Flags()> Enum FileAccess
.. . .
Dim a As FileAccess _
= FileAccess.faWriteShareRead Or FileAccess.faReadShare
? a.ToString()
"faWriteShareRead, faWriteShareWrite"

Note the inherent portability of the latter.

HTH,
Phill W.
Jun 9 '06 #4
Thank you GhostInAk and Phil W. for pointing out my error. Despite that, I
hope the explaination answers Jason's question.

"AMDRIT" <am****@hotmail.com> wrote in message
news:ON**************@TK2MSFTNGP03.phx.gbl...
I always think of enumerations as a logical grouping of numerical
constants. A bonus of enumerations is that you can assign multiple values
to a single variable.

enum fileaccess
faReadLock =0
faWriteLock=1
faReadShare=2
faWriteShareRead=4
faWriteShareWrite = 8
end enum

dim pintFileAccess as fileaccess = fileaccess.faWriteShareRead and
fileaccess.faWriteShareWrite

when you look at the properties of a control in the designer, many times
you will notice use of enumerations. Windows.WindowsState is an
enumeration

FormWindowState.Normal = 0,
FormWindowState.Minimized = 1 ,
FormWindowState.Maximized = 2

Enumerations reduce ambiguity

"Jason" <so*****@microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Can someone explain, or point me to a good link that explains
enumerations for a newbie.

Thats


Jun 9 '06 #5

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

Similar topics

1
by: Justin Wright | last post by:
I know that I can set up an enumeration as follows ( just typed in quick so may have syntax errors ): <xsd:simpleType name="colors"> <xsd:restriction base="xsd:string"> <xsd:enumeration...
0
by: Fender Mussel | last post by:
Hi all, Is it possible to check the content of a mixed type? I would like to define an enumeration for it. The following example works syntactically, but XMLSpy does no checks on the content at...
1
by: Sergey Poberezovskiy | last post by:
Hi, I have a simple enumeration in my schema: <xs:element name="el_1"> <xs:simpleType> <xs:restiction base="xs:string"> <xs:enumeration value="value and space 1"/> <xs:enumeration...
3
by: Antoine Junod | last post by:
Hello, I definitely have a problem to build a clean data structure. I would be very happy if some of you could help me as well as in the past. Here is my problem: -> I have a list of...
4
by: Marshal | last post by:
Sure... IEnumerable was inconvenient suggesting a separate class to service the enumeration, IEnumerator, and multiple operations: Current, MoveNext, Reset. (I'll warp the definition of "operation"...
3
by: Sampson | last post by:
I have a question about enumeration and how to populate them during runtime. I am using vb.net but will happily take any advice in c# as well. Here is an example to help illustrate what I am...
27
by: Ben Finney | last post by:
Antoon Pardon wrote: > I just downloaded your enum module for python > and played a bit with it. IMO some of the behaviour makes it less > usefull. Feedback is appreciated. I'm hoping to...
1
by: news.microsoft.com | last post by:
Hello, i got this attribute <xs:attribute name="jour"> <xs:simpleType> <xs:restriction base="stypeJour"> </xs:restriction> </xs:simpleType> </xs:attribute>
2
by: cj | last post by:
I see in VB.net 2003's help MessageBoxButtons enumeration, MessageBoxDefaultButton enumeration, MessageBoxIcon enumeration, and MessageBoxOptions enumeration but I don't see a listing of the...
1
by: stran | last post by:
I'm trying to create a simple type that holds two different types. The first is IDREF and the second is an enumeration of string. When I generate a sample xml, I can enter any ID previously stated in...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.