VS 2008 Get Assigned Enums With OR?

Jul 22, 2010

I realize this is probably trivial, but for some reason I'm not sure how to pull it off. Say I have the following enum:

Public Enum FlagType
Docs
Email

[Code]....

How do I then at runtime determine which flags where set for flags? In this example, it should be Docs and Email.

View 19 Replies


ADVERTISEMENT

Enums Error In Vb, How Is It Different From Enums In C#

Aug 3, 2011

I thought that enums in VB and C# where the same or at least very similar. Then today I stumbled across a bug in our VB code. The following VB code compiles and runs with no issues:

Enum Cars
Subaru
Volvo
End Enum

[code]....

Why does the VB version not catch the type mismatch? Are enum in VB and C# different?

View 2 Replies

VS 2008 Flag Enums In Property Grid

Jul 10, 2009

I have a flags enumeration property that I need to show in a property grid: [Code] In the property grid however, it only allows me to select a single value. I cannot combine the values like usual in a flags enum. How do I show something like a checked listbox in the property grid, so that the user can combine flags by checking items? A None and All item would be great but not required. [url]

But even that does not work properly. It seems to check and uncheck items arbitrarily. If you check the first and fourth item for example, the second and third items will sometimes be checked too. Yes, I realize that is supposed to happen with the TestEnum property (as that defines 'BottomRight' as 'Bottom Or Right', so that's logical), but it also happens with the SecurityFlags for example, which it shouldn't.

View 2 Replies

VS 2008 Variable Used Before Assigned Value?

Dec 25, 2011

Dim strSearch As String
strSearch = "[Player] Like '" & searchtext & "' AND [Year] Like '" & strYear & "' AND [Brand] Like '" & strBrand & "'"

[code].....

View 2 Replies

Make Picturebox1(function Already Assigned) Perform The Same Function As Picturebox2(no Function Assigned)

Aug 1, 2009

i wanted to ask how to make picturebox1 ,to which functions are already assigned, perform the same function as picturebox2 ,to which no functions are assigned.For example:I have already made picturebox1 and have assigned it alot of function like when play button is pressed then picturebox1.visible = true and when we press pause button picturebox1.visible = false. So now i decided to make a theme and have to remove the picturebox1 and want to allow the picturebox2 to havefunction of picturebox1.But when i disable the theme the function of picturebox1 should go back to picturebox1.

View 6 Replies

C# - How To Avoid Using Enums

Feb 15, 2010

Until asking a question on here I never considered (enums) to be a "bad thing." For those out there that consider them not to be best practice, what are some approachs/patterns for avoiding their use in code?

Edit:

public Enum SomeStatus
Approved = 1
Denied = 2
Pending =3
end Enum

View 5 Replies

Differences Between Enums In C#?

Jan 14, 2010

We have legacy character codes that we want to store as numbers in a new system. To increase readibility and general understanding in the code for devs making the migration, I want to do Enums like this..

[Code]...

With this setup, the code will be readable (imagine If Record.Status = Status.Open), and yet the values will be stored in the database as small numbers so it will be efficient. However... I am a VB.NET guy, but everybody wants to code in C#, so I need this sort of structure in C#.After Googling, I discovered the the general .NET equivalent of AscW is Convert.ToInt32("C"). When I try to use that statement in an enum, I get the compiler error "Constant Expression Required".

View 2 Replies

Enums Via Markup In .NET?

Oct 4, 2011

I have an enum and a usercontrol, both in the same assembly (a plain .NET 4 web site). In the Constants class:public Enum CrudOperations Add Edit Delete. This controls the columns in a GridView on a UserControl via a property on the UserControl

[Code]...

In C#, I've specified the columns to show with markup as Mode="Edit,Delete", but in VB.NET, this does nothing. The only way I can get anything to show is with the codebehind, but if on the containing page I use userGrid.Mode = CrudOperations.Edit And CrudOperations.Delete, I get all the columns (there's also a delete column), but userGrid.Mode = CrudOperations.Edit Or CrudOperations.Delete shows nothing.

View 1 Replies

Using Enums With INotifyPropertyChanged?

Mar 10, 2011

I have a public property, "Status" that is an enum. I have a setter method that changes the status and raises the PropertyChanged event. However, the WinForms user interface is not properly updating. I'm pretty sure it's because Status is an enum. Although I was thinking enum was a reference type but I guess it's a value type. Does INotifyPropertyChanged work the same with reference and value types?

[Code]...

View 3 Replies

'Enums.NoticeType' Is Not Defined

Nov 25, 2008

I work for a web hosting company and was handed a VB script which I apparently have to compile with some updated settings by 1 of our clients who knows less about it than I do. But when trying to compile the code I receive an error "'Enums.NoticeType' is not defined". As expected I haven't a clue. Am I missing some of the code, or do I have to add some libraries in my Visual Basic 2008 Express Edition? I have pasted the line of code below. If requested I can provide the whole script.

Code:
Public Function UpdateNotices(ByVal intNoticeID As Integer,
ByVal strNoticeTitle As String, ByVal dtDateFrom As Date, ByVal dtDateTo
As Date, ByVal intTypeID As Enums.NoticeType, ByVal boolPrimaryItem As
Boolean, ByVal boolActive As Boolean) As Int32

View 1 Replies

.net - Using VB Interfaces, Enums, Etc In C# Code?

Oct 20, 2011

I have a solution with multiple projects, some of the projects are written in VB, some in C#. I am wondering if there's a way to use interfaces and/or enums written in VB in C# classes? My C# code below doesn't compile, however I am able to see the interface in intellisense.

[Code]...

P.S It's a console/service application, not ASP.Net (where I know it's doable).UPD: Sorry guys, was missing a reference to the project with the interface. It's fixed now. I think the thing that in VB projects references are done slightly different than in C# confused me.

View 2 Replies

Asp.net - Overloading Enums And Properties In .NET?

Sep 23, 2010

I have a base class with the the following enum and property:

[Code]...

First off, how do I do this - is it by simply overloading it? And secondly will my original property pick up the new enum automatically when using the derived class or will I need to overload that too?

View 2 Replies

C# - Iterate All Public Enums?

Nov 22, 2010

We have a common component in our source which contains all the enums (approx 300!) for a very large application.Is there any way, using either C# or VB.NET, to iterate through all of them in order to perform an action on each one?

How to iterate all "public string" properties in a .net class is almost relevant but the enums I am dealing with are a mix of types.

View 5 Replies

C# - Use Flag-based .NET Enums From Lua?

Feb 16, 2012

I'm using LuaInterface for .NET to create Windows Forms objects. This works pretty good except for one thing:I want to use the Anchor property of Control to make them resize automatically. If I only set one of the Anchors (e.g. only AnchorStyles.Top), it works, but this doesn't really make sense. I have to set more than one Anchor, which is done by combining them with "bit-wise or" (or by just adding them numerically).

In VB.Net both works:
Dim myLabel As New Label()
myLabel.Anchor = AnchorStyles.Top[code]....

which is in a sense correct as "LuaInterface treats enumeration values as fields of the corresponding enumeration typ" (says LuaInterface: Scripting the .NET CLR with Lua).It is also not possible to assign the value as a number:

myLabel.Anchor = 15 -- 15 = 8 + 4 + 2 + 1 = Top+Left+Right+Bottom

This time, the error message is rather unspecific:

LuaInterface.LuaException: function

Is there a possibility to typecast the number to the correct enumeration type in Lua?

View 1 Replies

Defining C# Enums With Descriptions

Jan 27, 2010

What would the folowing VB.NET enum definition look like in C#? [code]

View 7 Replies

Enums - .NET Enumeration Representation?

Apr 16, 2010

Is it guaranteed that the numeric values for an Enum with only uninitialized values start at zero and increment by one in the order defined?

View 2 Replies

Using Enums In Project Settings?

Mar 10, 2009

I want to add a setting that uses an enum defined in form1.vb. All the research I've done suggests support for enum type settings is built-in and handled automatically by the VS IDE ... I assume this means it's as easy as defining font or color settings. However, I'm not having much. Are any of you gurus aware of how to set up an enum setting via the Project Settings UI?

View 8 Replies

VS 2010 : Using Strings In Enums?

Jan 9, 2012

Is there a way to use strings in Enums like the example below:

Enum myEnum
val1 = "some string 1"
val2 = "some string 2"
val3 = "some string etc"
End Enum

It seems like you can only use integers for the underlying values.

View 13 Replies

Declaring Enums Across Derived Classes

Sep 21, 2009

I am developing a program in VB.NET. I have an enum called PriceType that is declared in a super class ItemPriceBase. There are 3 classes that derive from ItemPriceBase - ItemPriceMeasured, ItemPriceNDI and ItemPriceExtraCost. The subset of PriceTypes for these classes are totally unique from each - Measured prices are 1 to 6, NDI prices are 7 to 15 and ExtraCost prices are 16 to 22.

Is there a way declare the enum in the super class and then extend the enum in each of the derived classes so that they only have access to those options, yet I can still access a property in the super class that returns an enum of PriceType?

View 3 Replies

Directcast & Ctype Differences With Enums?

Oct 13, 2009

Public Enum Fruit
Red_Apple = 1
Oranges
Ripe_Banana
End Enum
Private Sub InitCombosRegular()

[Code]...

Why does the Ctype work and the Directcast does not with the same syntax? Yet if I cast the selectedValue to an int before I DirectCast, then it works

View 1 Replies

Enums Can Be Only Declared As Integral Type?

Jan 7, 2010

i've got a custom integral type, and i want to be able to

Private Enum ENUM_Stuff As MyInteger

what i want to do: to know if there is anyway to make the above statement valid

View 7 Replies

C# - How To Group Enums Structures And Subclasses In Classes

Aug 21, 2010

I've heard bad things about overusing regions but when adding enums to my classes I put them into a #region "Enums" at the end of the class, and do the same with structures and even subclasses.

Is there a better/standard way to go about grouping such elements on classes?

(Note: this is tagged C#/VB but maybe the same situation exists for other languages, like Java)

View 1 Replies

.net - Handling Different DbType Enums In Database-Agnostic Architecture?

Apr 17, 2012

Here's my current set-up:

Public Interface IDatabase
Function CreateParameter(name as String, dbType as <dbTypeEnumeration>)
End Interface

[Code]....

The problem here is what exactly is dbTypeEnumeration. In the example above, it's simply a placeholder to what my problem is. Since we use both Oracle and SQL Server databases, the DbTypes are different depending on the database being used. For Oracle, the OracleClient object has its own OracleDbType enumeration with types. SQL Server also has its own enumeration.

My question is: is it possible to show those database-specific enumerations depending on which repository is injected into the DatabaseService constructor? If not, what's the best way to go about this? I want to separate the two databases, share logic, and allow for future development, ala the interface as a code contract for that development.

View 2 Replies

SQL - Store Enums At Database Level Or In Application Logic?

Jan 19, 2010

I have a table, lets call it Objects. It has a predefined set of records looking like this:
ObjectId ObjectName
1 Salmon
2 Trout
3 Seabass
4 Shark
Etc..

So, this I would like to implement somehow as an enum. But what's the best way, implement it in the database creating tables for it or in the application logic in an CommonEnums codebehind file etc?

View 2 Replies

.net - Using A Variable Before It Has Been Assigned A Value?

Apr 3, 2012

From the MSDN Article I read I should be using the StringBuilder rather than concatenating a normal string.However I do not know why I get the following errer: "Variable 'ShowString' is used before it has been assigned a value. A null reference exception could result at runtime."

[Code]...

View 1 Replies

Asp.net Variable Xyz Is Used Before It Has Been Assigned A Value

Nov 25, 2011

I am working with VS 2010 web VB 2010 asp.net..I am trying to read table data with the help of dataset.xsd..i create a loginDataSet.xsd and in index.aspx.vb web page i wrote this code [code] But it showing that abc variable is used before it has been assigned a value a null reference exception could result at the runtime .

View 5 Replies

Assigned IP To A CheckBox?

Jul 26, 2011

I made this code but I have problem to how assign IP addres to the checkbox.I try to make a remote shutdown program when any person select the checkbox make shutdown or reboot the select pc. this is the code:

Imports System.Net
Imports System.Net.Sockets
Imports System.Threading[code]....

View 8 Replies

Variable '' Is Used Before It Has Been Assigned?

Jul 13, 2009

I am using visual basic 2008How can i fix this problem:Warning1Variable 'bla' is used before it has been assigned a value. A null reference exception could result at runtime.

View 3 Replies

Variable Being Used Before It Has Been Assigned A Value

May 24, 2012

this is my first post I'm making a cheque book balance for my college assignment, which 1st form will record the data of the cheque (Cheque Number, Payee's Name & Cheque Amount) and this information would be stored to a .dat file. with the 2nd form will balance the Current balance in the account minus the cheque amount which has been stored in the .dat file and then will list it in a list box with the payee's name, cheque number, etc. I have used a module which is below:

[Code]...

View 5 Replies

Variable Is Used Before It Has Been Assigned A Value?

Nov 17, 2009

I'm getting the error message "Variable 'WordCreated' is used before it has been assigned a value..."As such, VB is not even letting me assign a value to any slots in the array.

Dim WordCreated() As String
WordCreated(0) = "Hello!"
That's just a snippet of my code, when declaring the variables. The "Hello!" part has just

[code].....

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved