Darc Posted September 14, 2003 Posted September 14, 2003 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? Quote
Administrators PlausiblyDamp Posted September 14, 2003 Administrators Posted September 14, 2003 Enum Number one two three End Enum should do it. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Darc Posted September 15, 2003 Author Posted September 15, 2003 I do that but how do I declare the variable so its both? Quote
Moderators Robby Posted September 15, 2003 Moderators Posted September 15, 2003 do you mean... Public Enum Number one = 1 two = 2 three = 1 End Enum Quote Visit...Bassic Software
Darc Posted September 15, 2003 Author Posted September 15, 2003 no I mean the variable that's declared as a Number, how would I make it 1 and 2 at the same time? Quote
Moderators Robby Posted September 15, 2003 Moderators Posted September 15, 2003 Number is not a variable. Quote Visit...Bassic Software
Darc Posted September 15, 2003 Author Posted September 15, 2003 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 Quote
Moderators Robby Posted September 15, 2003 Moderators Posted September 15, 2003 That's not what an enum is used for. Perhaps you can use a Property instead. Quote Visit...Bassic Software
AndreRyan Posted September 15, 2003 Posted September 15, 2003 (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 September 15, 2003 by AndreRyan Quote .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* Volte Posted September 15, 2003 *Experts* Posted September 15, 2003 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. Quote
AlexCode Posted September 16, 2003 Posted September 16, 2003 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... Quote Software bugs are impossible to detect by anybody except the end user.
Darc Posted September 16, 2003 Author Posted September 16, 2003 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... Quote
AlexCode Posted September 16, 2003 Posted September 16, 2003 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... Quote Software bugs are impossible to detect by anybody except the end user.
Darc Posted September 17, 2003 Author Posted September 17, 2003 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") Quote
*Experts* mutant Posted September 17, 2003 *Experts* Posted September 17, 2003 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 Quote
AlexCode Posted September 17, 2003 Posted September 17, 2003 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 Quote Software bugs are impossible to detect by anybody except the end user.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.