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

Using Enum

Hi ,

I have 2 Questions About Using Enum

1) i have the following Enum under my class but if i need to use it i must
use it like this

ConstantsFileSystem.CREATE_FILE

how can i use it just by the const name by doing like this CREATE_FILE

Public Enum ConstantsFileSystem

CREATE_FILE = 0

APPEND_FILE = 1

OVERWRITE_FILE = 2

End Enum

2) is it good to use Enum for public params which i need to use all over my
Assemblies ? (if not please recommend a better way)
Best Regards ,

Tiraman :-)
Nov 20 '05 #1
7 3336
* "Tiraman" <ti*****@netvision.net.il> scripsit:
I have 2 Questions About Using Enum

1) i have the following Enum under my class but if i need to use it i must
use it like this

ConstantsFileSystem.CREATE_FILE

how can i use it just by the const name by doing like this CREATE_FILE

Public Enum ConstantsFileSystem

CREATE_FILE = 0

APPEND_FILE = 1

OVERWRITE_FILE = 2

End Enum
'Imports ConstantsFileSystem' on top of the file in which you want to
use the constants without qualifying them (I am not sure that this makes
much sense).
2) is it good to use Enum for public params which i need to use all over my
Assemblies ? (if not please recommend a better way)


Why not?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
"Tiraman" <ti*****@netvision.net.il> schrieb
Hi ,

I have 2 Questions About Using Enum

1) i have the following Enum under my class but if i need to use it i
must use it like this

ConstantsFileSystem.CREATE_FILE

how can i use it just by the const name by doing like this
CREATE_FILE

Public Enum ConstantsFileSystem

CREATE_FILE = 0

APPEND_FILE = 1

OVERWRITE_FILE = 2

End Enum
Why? CREATE_FILE and the other constants could also be part of another Enum.
In addition, auto-complete automatically inserts the full name, so I don't
see the problem.

(BTW, there is System.IO.FileMode already)
2) is it good to use Enum for public params which i need to use all
over my Assemblies ? (if not please recommend a better way)


Well, I think it's good. :-)
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
Hi,

Well you are right .
i added the import in the top of my assembly and i added a reference to the
file which is a regular TLB file and not a DOT NET file !
And now its ok .

BUT when i m trying to compile my DLL i m getting the following error :

vbc : error BC31011: Unable to load referenced library
'c:\DLL\NanaConstants.tlb': System Error &H8013110b&
c:\DLL\NanaConstants.tlb : error BC31011: Unable to load referenced
library 'c:\DLL\NanaConstants.tlb': System Error &H8013110b&
vbc : error BC30142: Unable to generate a reference to file
'c:\DLL\NanaConstants.tlb'
(use TLBIMP utility to reference COM DLLs): unable to load
international DLL: VBC7ui.dll
C:\Components\General.vb(6) : error BC30466: Namespace or type
'ConstantsFileSystem' for the Imports 'NanaLib.ConstantsFileSystem' cannot
be found.

Imports NanaLib.ConstantsFileSystem
~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Components\General.vb(93) : error BC30451: Name 'naCREATE_FILE' is
not declared.

Optional ByVal Method As Integer =
naCREATE_FILE, _

~~~~~~~~~~~~~

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c6************@ID-208219.news.uni-berlin.de...
* "Tiraman" <ti*****@netvision.net.il> scripsit:
I have 2 Questions About Using Enum

1) i have the following Enum under my class but if i need to use it i must use it like this

ConstantsFileSystem.CREATE_FILE

how can i use it just by the const name by doing like this CREATE_FILE

Public Enum ConstantsFileSystem

CREATE_FILE = 0

APPEND_FILE = 1

OVERWRITE_FILE = 2

End Enum


'Imports ConstantsFileSystem' on top of the file in which you want to
use the constants without qualifying them (I am not sure that this makes
much sense).
2) is it good to use Enum for public params which i need to use all over my Assemblies ? (if not please recommend a better way)


Why not?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #4
Hello Armin ,

you are right about the FileMode but i m asking in general
lets say that i have my own Enum but they are all in an old TLB file (which
is not in .NET) and i read that i can import and reference it to my project
and then it will be recognized all over which is true but as i wrote b4 i m
have problems with the compilation .

10x
"Armin Zingler" <az*******@freenet.de> wrote in message
news:40***********************@news.freenet.de...
"Tiraman" <ti*****@netvision.net.il> schrieb
Hi ,

I have 2 Questions About Using Enum

1) i have the following Enum under my class but if i need to use it i
must use it like this

ConstantsFileSystem.CREATE_FILE

how can i use it just by the const name by doing like this
CREATE_FILE

Public Enum ConstantsFileSystem

CREATE_FILE = 0

APPEND_FILE = 1

OVERWRITE_FILE = 2

End Enum
Why? CREATE_FILE and the other constants could also be part of another

Enum. In addition, auto-complete automatically inserts the full name, so I don't
see the problem.

(BTW, there is System.IO.FileMode already)
2) is it good to use Enum for public params which i need to use all
over my Assemblies ? (if not please recommend a better way)


Well, I think it's good. :-)
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5
"Tiraman" <ti*****@netvision.net.il> schrieb
Hi,

Well you are right .
i added the import in the top of my assembly and i added a reference
to the file which is a regular TLB file and not a DOT NET file !
And now its ok .
How did you add the reference? Either use "add reference" -> COM tab, or use
the tlbimp tool to create an interop wrapper dll that can be referenced by
pressing the "browse" button on the first folder of the "add reference"
dialog.
BUT when i m trying to compile my DLL i m getting the following error
:
vbc : error BC31011: Unable to load referenced library
'c:\DLL\NanaConstants.tlb': System Error &H8013110b&
c:\DLL\NanaConstants.tlb : error BC31011: Unable to load
referenced
library 'c:\DLL\NanaConstants.tlb': System Error &H8013110b&
vbc : error BC30142: Unable to generate a reference to file
'c:\DLL\NanaConstants.tlb'
(use TLBIMP utility to reference COM DLLs): unable to load
international DLL: VBC7ui.dll
C:\Components\General.vb(6) : error BC30466: Namespace or type
'ConstantsFileSystem' for the Imports 'NanaLib.ConstantsFileSystem'
cannot be found.

Imports NanaLib.ConstantsFileSystem
~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Components\General.vb(93) : error BC30451: Name
'naCREATE_FILE' is
not declared.

Optional ByVal Method As Integer =
naCREATE_FILE, _


--
Armin

Nov 20 '05 #6
* "Tiraman" <ti*****@netvision.net.il> scripsit:
i added the import in the top of my assembly and i added a reference to the
file which is a regular TLB file and not a DOT NET file !
And now its ok .


The enum is defined inside a COM DLL?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #7
well
first let me say that every thing ok now :-)
i used the tlbimp tool in order to convert the COM TLB
in to assembly and i put that assembly in the GAC
And now i m using it all over :-)

So 10x again to both of you .

Bye

"Armin Zingler" <az*******@freenet.de> wrote in message
news:40*********************@news.freenet.de...
"Tiraman" <ti*****@netvision.net.il> schrieb
Hi,

Well you are right .
i added the import in the top of my assembly and i added a reference
to the file which is a regular TLB file and not a DOT NET file !
And now its ok .
How did you add the reference? Either use "add reference" -> COM tab, or

use the tlbimp tool to create an interop wrapper dll that can be referenced by
pressing the "browse" button on the first folder of the "add reference"
dialog.
BUT when i m trying to compile my DLL i m getting the following error
:
vbc : error BC31011: Unable to load referenced library
'c:\DLL\NanaConstants.tlb': System Error &H8013110b&
c:\DLL\NanaConstants.tlb : error BC31011: Unable to load
referenced
library 'c:\DLL\NanaConstants.tlb': System Error &H8013110b&
vbc : error BC30142: Unable to generate a reference to file
'c:\DLL\NanaConstants.tlb'
(use TLBIMP utility to reference COM DLLs): unable to load
international DLL: VBC7ui.dll
C:\Components\General.vb(6) : error BC30466: Namespace or type
'ConstantsFileSystem' for the Imports 'NanaLib.ConstantsFileSystem'
cannot be found.

Imports NanaLib.ConstantsFileSystem
~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Components\General.vb(93) : error BC30451: Name
'naCREATE_FILE' is
not declared.

Optional ByVal Method As Integer =
naCREATE_FILE, _


--
Armin

Nov 20 '05 #8

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

Similar topics

11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
1
by: Xiangliang Meng | last post by:
Hi, all. Recently, I find there is a way in our project to maintain a global set in many files by using preprocessing directives. I'm wondering if we could find a better method for this. Many...
3
by: Richard | last post by:
I have a requirement to put a GDI style circle or rectangle border around the selected row of a datagrid/ It will overlap into the row above and below the selected row. Doing this in a the OnPaint...
6
by: Brian Haynes | last post by:
I've read all the posts in this forum that I can find that look related to this issue and I have only found 1 solution that I consider to be a bit of a hack. What I want to do is assign a value to...
1
by: Chris Dunaway | last post by:
Suppose I have the following enum: public enum MyEnum { EnumVal1 = 1, EnumVal2 = 2, EnumVal3 = 3 } I want to serialize the enum but I want the /names/ of the enum to be stored in the .xml...
10
by: Rick Palmer | last post by:
I have an app I'm working on that will allow a user to run one of 5 reports. The report names are in a combobox on my form. I have a sub defined for each report that has the exact same name as is...
13
by: Don | last post by:
How do I get an Enum's type using only the Enum name? e.g. Dim enumType as System.Type Dim enumName as String = "MyEnum" enumType = ???(enumName)
6
by: ransoma22 | last post by:
I developing an application that receive SMS from a connected GSM handphone, e.g Siemens M55, Nokia 6230,etc through the data cable. The application(VB.NET) will receive the SMS automatically,...
7
by: Harris | last post by:
Dear all, I have the following codes: ====== public enum Enum_Value { Value0 = 0, Value1 = 10,
2
by: puzzlecracker | last post by:
I am porting old java code to csharp and now facing a stumbling block. Before advent of enum in Java, developers used enum-like structures, shown below. However, AFAIK, CSharp isn't lacking this...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
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,...

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.