By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,881 Members | 1,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,881 IT Pros & Developers. It's quick & easy.

declare argument to ccept OR

P: n/a
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.
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


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

-CJ
"Cc" <ko*****@singnet.com.sg> wrote in message
news:OO**************@tk2msftngp13.phx.gbl...
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.

Nov 20 '05 #2

P: n/a
"Cc" <ko*****@singnet.com.sg> schrieb
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
--
Armin

Nov 20 '05 #3

P: n/a
Hello,

"Cc" <ko*****@singnet.com.sg> schrieb:
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
///

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.