473,785 Members | 2,307 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB 2005 BitVector32

Hello,

I need some help on the BitVector32 class.

I'm trying to create a function like:

Private Sub Function (ByVal Input as integer, ByVal Bitnr as integer,
ByVal BitHigh as Boolean) As Integer

Return Output
End Function

The function must return a new integer value, with the proper bitnumber set
true or false.

Thanks

Hans
May 16 '07 #1
5 2131
Hello Hans,

you can do this with this function:

Private Shared Function IsFlagSet(ByVal value As Integer, ByVal bitNr As
Integer) As Boolean
If ((bitNr < 0) OrElse (bitNr 31)) Then
Throw New ArgumentOutOfRa ngeException("b itNr")
End If
Return (((value >bitNr) And 1) = 1)
End Function

Best regards,
Henning Krause
"Hans" <Ha**@discussio ns.microsoft.co mwrote in message
news:1C******** *************** ***********@mic rosoft.com...
Hello,

I need some help on the BitVector32 class.

I'm trying to create a function like:

Private Sub Function (ByVal Input as integer, ByVal Bitnr as integer,
ByVal BitHigh as Boolean) As Integer

Return Output
End Function

The function must return a new integer value, with the proper bitnumber
set
true or false.

Thanks

Hans

May 16 '07 #2
Hello Henning,

Thanks for your resaction,

But i don't want to know if the bit is set or not.
Sample:

Private Sub Function SetBitInt32 (ByVal Input as integer, ByVal Bitnr as
integer,
ByVal BitHigh as Boolean) As Integer

Dim Output as Integer
Dim BV As New BitVector32(Inp ut)

" Then set the Bitnr in the Input , BitHigh True or False"
" Return the Output Integer"

Return Output

End Function

I would like to use the BitVector32 class.
Best regards,
Hans

"Henning Krause [MVP - Exchange]" wrote:
Hello Hans,

you can do this with this function:

Private Shared Function IsFlagSet(ByVal value As Integer, ByVal bitNr As
Integer) As Boolean
If ((bitNr < 0) OrElse (bitNr 31)) Then
Throw New ArgumentOutOfRa ngeException("b itNr")
End If
Return (((value >bitNr) And 1) = 1)
End Function

Best regards,
Henning Krause
"Hans" <Ha**@discussio ns.microsoft.co mwrote in message
news:1C******** *************** ***********@mic rosoft.com...
Hello,

I need some help on the BitVector32 class.

I'm trying to create a function like:

Private Sub Function (ByVal Input as integer, ByVal Bitnr as integer,
ByVal BitHigh as Boolean) As Integer

Return Output
End Function

The function must return a new integer value, with the proper bitnumber
set
true or false.

Thanks

Hans

May 16 '07 #3
Hello,

you can do this with your own function like this:

Private Shared Function SetBit(ByVal value As Integer, ByVal bitNr As
Integer, ByVal state As Boolean) As Integer
If ((bitNr < 0) OrElse (bitNr &H1F)) Then
Throw New ArgumentOutOfRa ngeException("b itNr")
End If
Dim mask As Integer = (CInt(1) << bitNr)
If state Then
value = (value Or mask)
Else
value = (value And Not mask)
End If
Return value
End Function

Best regards,
Henning Krause
"Hans" <Ha**@discussio ns.microsoft.co mwrote in message
news:D3******** *************** ***********@mic rosoft.com...
Hello Henning,

Thanks for your resaction,

But i don't want to know if the bit is set or not.
Sample:

Private Sub Function SetBitInt32 (ByVal Input as integer, ByVal Bitnr as
integer,
ByVal BitHigh as Boolean) As Integer

Dim Output as Integer
Dim BV As New BitVector32(Inp ut)

" Then set the Bitnr in the Input , BitHigh True or False"
" Return the Output Integer"

Return Output

End Function

I would like to use the BitVector32 class.
Best regards,
Hans

"Henning Krause [MVP - Exchange]" wrote:
>Hello Hans,

you can do this with this function:

Private Shared Function IsFlagSet(ByVal value As Integer, ByVal bitNr As
Integer) As Boolean
If ((bitNr < 0) OrElse (bitNr 31)) Then
Throw New ArgumentOutOfRa ngeException("b itNr")
End If
Return (((value >bitNr) And 1) = 1)
End Function

Best regards,
Henning Krause
"Hans" <Ha**@discussio ns.microsoft.co mwrote in message
news:1C******* *************** ************@mi crosoft.com...
Hello,

I need some help on the BitVector32 class.

I'm trying to create a function like:

Private Sub Function (ByVal Input as integer, ByVal Bitnr as integer,
ByVal BitHigh as Boolean) As Integer

Return Output
End Function

The function must return a new integer value, with the proper bitnumber
set
true or false.

Thanks

Hans


May 16 '07 #4
Hello,

Thanks,

Your function works great.

But i would like to know how the bitvector32 class works.
Can i have the same functionality with that class ?
Best Regards,

Hans
"Henning Krause [MVP - Exchange]" wrote:
Hello,

you can do this with your own function like this:

Private Shared Function SetBit(ByVal value As Integer, ByVal bitNr As
Integer, ByVal state As Boolean) As Integer
If ((bitNr < 0) OrElse (bitNr &H1F)) Then
Throw New ArgumentOutOfRa ngeException("b itNr")
End If
Dim mask As Integer = (CInt(1) << bitNr)
If state Then
value = (value Or mask)
Else
value = (value And Not mask)
End If
Return value
End Function

Best regards,
Henning Krause
"Hans" <Ha**@discussio ns.microsoft.co mwrote in message
news:D3******** *************** ***********@mic rosoft.com...
Hello Henning,

Thanks for your resaction,

But i don't want to know if the bit is set or not.
Sample:

Private Sub Function SetBitInt32 (ByVal Input as integer, ByVal Bitnr as
integer,
ByVal BitHigh as Boolean) As Integer

Dim Output as Integer
Dim BV As New BitVector32(Inp ut)

" Then set the Bitnr in the Input , BitHigh True or False"
" Return the Output Integer"

Return Output

End Function

I would like to use the BitVector32 class.
Best regards,
Hans

"Henning Krause [MVP - Exchange]" wrote:
Hello Hans,

you can do this with this function:

Private Shared Function IsFlagSet(ByVal value As Integer, ByVal bitNr As
Integer) As Boolean
If ((bitNr < 0) OrElse (bitNr 31)) Then
Throw New ArgumentOutOfRa ngeException("b itNr")
End If
Return (((value >bitNr) And 1) = 1)
End Function

Best regards,
Henning Krause
"Hans" <Ha**@discussio ns.microsoft.co mwrote in message
news:1C******** *************** ***********@mic rosoft.com...
Hello,

I need some help on the BitVector32 class.

I'm trying to create a function like:

Private Sub Function (ByVal Input as integer, ByVal Bitnr as integer,
ByVal BitHigh as Boolean) As Integer

Return Output
End Function

The function must return a new integer value, with the proper bitnumber
set
true or false.

Thanks

Hans




May 16 '07 #5
Hello Henning,

Thanks for putting me in the right direction.

This is my solution with the bitvector32 class.
Public Function SetInt32Bit(ByV al iInputInt32 As Integer, ByVal iBitNr
As Integer, ByVal State As Boolean) As Integer

Dim output As Integer

Dim myBit(31) As Integer

For i As Integer = 0 To 31
If i = 0 Then
myBit(i) = BitVector32.Cre ateMask()
Else
myBit(i) = BitVector32.Cre ateMask(myBit(i - 1))
End If
Next

If State = True Then
output = iInputInt32 Or myBit(iBitNr)
Else
output = iInputInt32 And Not myBit(iBitNr)
End If
Return output

End Function

Best regards,

Hans

"Henning Krause [MVP - Exchange]" wrote:
Hello,

you can do this with your own function like this:

Private Shared Function SetBit(ByVal value As Integer, ByVal bitNr As
Integer, ByVal state As Boolean) As Integer
If ((bitNr < 0) OrElse (bitNr &H1F)) Then
Throw New ArgumentOutOfRa ngeException("b itNr")
End If
Dim mask As Integer = (CInt(1) << bitNr)
If state Then
value = (value Or mask)
Else
value = (value And Not mask)
End If
Return value
End Function

Best regards,
Henning Krause
"Hans" <Ha**@discussio ns.microsoft.co mwrote in message
news:D3******** *************** ***********@mic rosoft.com...
Hello Henning,

Thanks for your resaction,

But i don't want to know if the bit is set or not.
Sample:

Private Sub Function SetBitInt32 (ByVal Input as integer, ByVal Bitnr as
integer,
ByVal BitHigh as Boolean) As Integer

Dim Output as Integer
Dim BV As New BitVector32(Inp ut)

" Then set the Bitnr in the Input , BitHigh True or False"
" Return the Output Integer"

Return Output

End Function

I would like to use the BitVector32 class.
Best regards,
Hans

"Henning Krause [MVP - Exchange]" wrote:
Hello Hans,

you can do this with this function:

Private Shared Function IsFlagSet(ByVal value As Integer, ByVal bitNr As
Integer) As Boolean
If ((bitNr < 0) OrElse (bitNr 31)) Then
Throw New ArgumentOutOfRa ngeException("b itNr")
End If
Return (((value >bitNr) And 1) = 1)
End Function

Best regards,
Henning Krause
"Hans" <Ha**@discussio ns.microsoft.co mwrote in message
news:1C******** *************** ***********@mic rosoft.com...
Hello,

I need some help on the BitVector32 class.

I'm trying to create a function like:

Private Sub Function (ByVal Input as integer, ByVal Bitnr as integer,
ByVal BitHigh as Boolean) As Integer

Return Output
End Function

The function must return a new integer value, with the proper bitnumber
set
true or false.

Thanks

Hans




May 18 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
3710
by: Chua Wen Ching | last post by:
Hi there, I saw this article here in vb.net. http://www.error-bank.com/microsoft.public.dotnet.languages.vb.1/148992_Thread.aspx and http://www.opennetcf.org/forums/post.asp?method=ReplyQuote&REPLY_ID=3922&TOPIC_ID=2224&FORUM_ID=35
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9489
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10357
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10162
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4063
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.