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

Home Posts Topics Members FAQ

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

ConstantsFileSy stem.CREATE_FIL E

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

Public Enum ConstantsFileSy stem

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 3357
* "Tiraman" <ti*****@netvis ion.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

ConstantsFileSy stem.CREATE_FIL E

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

Public Enum ConstantsFileSy stem

CREATE_FILE = 0

APPEND_FILE = 1

OVERWRITE_FILE = 2

End Enum
'Imports ConstantsFileSy stem' 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*****@netvis ion.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

ConstantsFileSy stem.CREATE_FIL E

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

Public Enum ConstantsFileSy stem

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.FileM ode 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\NanaCon stants.tlb': System Error &H8013110b&
c:\DLL\NanaCons tants.tlb : error BC31011: Unable to load referenced
library 'c:\DLL\NanaCon stants.tlb': System Error &H8013110b&
vbc : error BC30142: Unable to generate a reference to file
'c:\DLL\NanaCon stants.tlb'
(use TLBIMP utility to reference COM DLLs): unable to load
international DLL: VBC7ui.dll
C:\Components\G eneral.vb(6) : error BC30466: Namespace or type
'ConstantsFileS ystem' for the Imports 'NanaLib.Consta ntsFileSystem' cannot
be found.

Imports NanaLib.Constan tsFileSystem
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
C:\Components\G eneral.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*****@netvis ion.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

ConstantsFileSy stem.CREATE_FIL E

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

Public Enum ConstantsFileSy stem

CREATE_FILE = 0

APPEND_FILE = 1

OVERWRITE_FILE = 2

End Enum


'Imports ConstantsFileSy stem' 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*******@free net.de> wrote in message
news:40******** *************** @news.freenet.d e...
"Tiraman" <ti*****@netvis ion.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

ConstantsFileSy stem.CREATE_FIL E

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

Public Enum ConstantsFileSy stem

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.FileM ode 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*****@netvis ion.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\NanaCon stants.tlb': System Error &H8013110b&
c:\DLL\NanaCons tants.tlb : error BC31011: Unable to load
referenced
library 'c:\DLL\NanaCon stants.tlb': System Error &H8013110b&
vbc : error BC30142: Unable to generate a reference to file
'c:\DLL\NanaCon stants.tlb'
(use TLBIMP utility to reference COM DLLs): unable to load
international DLL: VBC7ui.dll
C:\Components\G eneral.vb(6) : error BC30466: Namespace or type
'ConstantsFileS ystem' for the Imports 'NanaLib.Consta ntsFileSystem'
cannot be found.

Imports NanaLib.Constan tsFileSystem
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
C:\Components\G eneral.vb(93) : error BC30451: Name
'naCREATE_FILE' is
not declared.

Optional ByVal Method As Integer =
naCREATE_FILE, _


--
Armin

Nov 20 '05 #6
* "Tiraman" <ti*****@netvis ion.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*******@free net.de> wrote in message
news:40******** *************@n ews.freenet.de. ..
"Tiraman" <ti*****@netvis ion.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\NanaCon stants.tlb': System Error &H8013110b&
c:\DLL\NanaCons tants.tlb : error BC31011: Unable to load
referenced
library 'c:\DLL\NanaCon stants.tlb': System Error &H8013110b&
vbc : error BC30142: Unable to generate a reference to file
'c:\DLL\NanaCon stants.tlb'
(use TLBIMP utility to reference COM DLLs): unable to load
international DLL: VBC7ui.dll
C:\Components\G eneral.vb(6) : error BC30466: Namespace or type
'ConstantsFileS ystem' for the Imports 'NanaLib.Consta ntsFileSystem'
cannot be found.

Imports NanaLib.Constan tsFileSystem
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
C:\Components\G eneral.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
6607
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 where the job is running, the job runs sucessfully, PDF files got generated, everything is good. If I scheduled the job to run at the time that I am not logged into the server, Access is not able to print to the printer. The error is pretty...
1
2763
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 colors are referred in different subsystems in our projects. They are defined as enumeration constants and a single color must be the same value all across our projects.
3
4268
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 of a subclassed DataGridTextBoxColum dos not seem like a practical way to do it. I have subclassed a DataGrid and overridden the OnPaint as such:
6
28607
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 an enum variable using an int. What I am using right now is something like this: public enum MyEnum { value1, value2, value3
1
15762
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 file, like this:
10
5046
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 displayed in the combobox. I have one button on the form to start processing. What I want to do is this: When the user selects the report they want to run from the combobox, I want to dynamically bind the appropriate sub to the button's click...
13
12395
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
17208
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, process and output to the screen in my application when a message arrived. But the problem is how do I read the SMS message immediately when it arrived without my handphone BeEPINg for new message ? I read up the AT commands, but when getting down...
7
9838
by: Harris | last post by:
Dear all, I have the following codes: ====== public enum Enum_Value { Value0 = 0, Value1 = 10,
2
1472
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 particular feature, and I don't want to port it in an old way. Here is the code below (in java ) that I want to approximate in C#. Note that I have lots of classes that follow this sort of principles. public class Derived extends Base {
0
9587
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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
10340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10324
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
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...
2
3827
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.