declare argument to ccept OR

C

Cc

hi,
how do I create function that allow argument to accept combine enum using
OR. and how do I extract the argument value inside the function.
 
C

CJ Taylor

Look into Polymorphism... you want to overload a method declaration to
handle different "scenarios" of how data is passed into the fucntion.

-CJ
 
A

Armin Zingler

Cc said:
hi,
how do I create function that allow argument to accept combine enum
using OR. and how do I extract the argument value inside the
function.

<Flags()> _
Public Enum MyEnum
a = 1
b = 2
c = 4
End Enum
Sub test(ByVal param As MyEnum)
If (param And MyEnum.a) = MyEnum.a Then
'a is set
End If
End Sub
Sub AnotherTest()
test(MyEnum.a Or MyEnum.b)
End Sub
 
H

Herfried K. Wagner [MVP]

Hello,

Cc said:
how do I create function that allow argument to accept
combine enum using OR. and how do I extract the
argument value inside the function.

\\\
<Flags()> _
Public Enum Bla
Const1 = 1
Const2 = 2
Const3 = 4
Const4 = 8
End Enum
..
..
..
Foo(Bla.Const2 Or Bla.Const4)
..
..
..
Public Sub Foo(ByVal x As Bla)
MsgBox(((x And Bla.Const2) = Bla.Const2).ToString())
End Sub
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top