Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

ok, I have an enumeration, say:

 

Enum Number
   one
   two
   three
End Enum

 

how can I make a variable equal one AND three at the same time?

so:

 

If x = Number.One And x = Number.Three

returns true?

Posted

I mean declaring it as the Enumeration Number!

 

Enum Number
   one = 1
   two = 2
End Enum

Private Sub SomeSub()
  Dim x As Number = ???
End Sub

Posted (edited)

Do you mean:

Dim x as Number = Number.One Or Number.Two
If (x And Number.One) = Number.One Then 'Enum contains 1 so True

Note the above only works if you use: 1,2,4,8 (^2) numbers. I think there's another method using Xor that's more effective though

Edited by AndreRyan
.Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?
  • *Experts*
Posted

re: AndreRyan

 

If you specify the FlagsAttribute attribute on the Enum and leave out the enum id for each element, it will do the expontential numbering for you.

 

As far as I'm aware, the And method is the best way to do it.

Posted

I think nobody understood your problem... neither did I! :)

 

So, explain it better... I would recomend that you start explaining why would you ever want to have one single valriable, ha 2 values of an ENUM at the same time... Maybe we find you another way aroung cause I don't find it possible! :D

 

I'll be waiting...

Software bugs are impossible to detect by anybody except the end user.
Posted
I'm making a Online Card Game with MANY keywords (think MTG) And I don't want to make literally 50 boolean properties and arguments per function...
Posted

Let me see if I got it...

The ENUM have all the cards and you wnat to have a variable to handle all the cards of each player?

Is that it?

 

If it isn't I still don't get it... sorry...

Software bugs are impossible to detect by anybody except the end user.
Posted
No, the KEYWORDS on the cards :) Like, Creature or Building, they're just status of the card so I need to have more than one on a card (like "Strong" and "Creature")
  • *Experts*
Posted

I think im somehow beginning to understand you :).

If they have different values then it wouldnt make sense that one variable could have two different ones. What about making a structure or a class that will hold two variables of that enumeration type and you assign the enumaration values to them. Something like this:

Public Structure Card
Dim firsttype As Number
Dim secondtype As Number
End Structure

Posted

I don't know if those keywords have a fixed max value or not...

If so, the mutants idea is perfect, You put the structure on the array of cards and there you go ... If not you'll have to use a second array. Each item on the array of cards have an array in it with all the keywords of each card...

 

Solved ?? :D

Software bugs are impossible to detect by anybody except the end user.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...