| re: Correct way to combine MsgboxStyles
Hi paragpdoke,
The MsgBoxStyle is an enumeration defined with the Flags attribute. That means you should use bitwise operations against them rather than arithmetic operations.
In terms of the examples you've posted I would say the first one is incorrect as it uses an arithmetic operator. That would probably give you the underlying integer values of MsgBoxStyle.Question and MsgBoxStyle.YesNo added together, which may or may not equate to another member of the enumeration, which, although allowed, is more than likely not what you're looking for.
Not that knowledgeable on VB, but the second one looks like VB syntax and would be equivalent to the third one which looks like C# syntax. Both OR the two flags together.
Of course you can always AND the flags together. This would use "And" in VB or the & operator in C#.
It may be worth looking up some resources on Bitwise operators and how they work in both VB and C#.
Hope this helps. :)
|