Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Let's explain myself.

I have a method to get an objet and is fellow data. The objet himself is a student, the fellow data are his address, his classes, his notes...and so on. I want a method where I can get only what I want.

 

Method Get(byval studentID as long, byval withAddress as boolean, byval with classes as boolean, byval with......)

 

It's a lot of parameters! I thought about using bit to know if an option is set.

 

Public Enum Options As Byte

Option1 = 1

Option2 = 2

Option3 = 4

Option4 = 8

Option5 = 16

Option6 = 32

End Enum

 

Method Get(byval studentID as long, byval opt as Options)

 

When I call the method, I can do

 

Get(34,Options.Option2 Or Options.Options5)

 

Then the byte representation should be

10010

 

So I know that Option2 is set and Option 5 is set.

 

Now it's where My problem is. Inside my Get method, I don't know how to analyse the byte to know that Option2 is set and Option 5 is set.

 

Do you know how can I get the binary representation of a byte and then check is bit to know if the option is set or not?

 

Thank you

Martin

Posted
Public Enum Options
Option1 = 1
Option2 = 2
Option3 = 4
Option4 = 8
Option5 = 16
Option6 = 32
End Enum

Dim E as Options = Options.Option1 Or Options.Option5
If (E And Options.Option5) = Options.Option5 Then
   Msgbox("Contained option5")
End If

.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?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...