ChubbyArse Posted November 14, 2003 Posted November 14, 2003 Hi All, I want to do something like the flags property in the old commondialog. Where you used the OR to specifiy the options, I'd like to build the same into my function call. How do I do this. For example: Dim lng As Long lng = 1 Or 2 How do I establish that lng contains 1 and 2? What is this technique described as in vb.net, and where would I be able to read up on it? Thanks Alex Quote
Administrators PlausiblyDamp Posted November 14, 2003 Administrators Posted November 14, 2003 easier way is to use an enum with the flags attribute public enum FlagTest Flag1 Flag2 Flag3 etc end enum look in help for enum / flags Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
ChubbyArse Posted November 14, 2003 Author Posted November 14, 2003 Am I able to use the FlagsAttribute when my enum is numbers as such???? <FlagsAttribute()> Public Enum CustomCCItemType As Long Drawing = 1 PNumber = 2 ConsumablePNumber = 3 RepairSalvageDrawing = 4 ProcurementDS = 5 LOP = 6 WeightReport = 7 Modification = 8 Amendment = 9 MagneticTape = 10 DesignSpecification = 11 ToolDrawing = 12 TestRig = 13 TestRigDrawing = 14 StandardPart = 15 End Enum The reason they are numbered is that they correspond to a reference key in a table which I want to build a search SQL string for. What I am reading is that a flags enum has to be numbered 1,2,4,8,16 etc...... In that case, how can I use this enum as a flag? Quote
Administrators PlausiblyDamp Posted November 14, 2003 Administrators Posted November 14, 2003 Flags are really just bit fields behind the scenes so the powers of 2 numbering is required for exclusive options. Using your example of Drawing = 1 PNumber = 2 ConsumablePNumber = 3 ConsumablePNumber would logically be the combiniation of Drawing and PNumber - probably not how your logic works. It may be easier to declare your function as taking an array of options and passing multiple values in that way. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
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.