Re: How do i change numerics into binary numbers?
- From: "mayayana" <mayaXXyana1a@xxxxxxxxxxxxxxxx>
- Date: Mon, 02 Oct 2006 00:58:18 GMT
So you want the binary 1/0 string for a given
number? You don't want Base64 conversion?
------------------------------------
Public Function Dec2Bin(ByVal DecimalIn As Long, _
Optional NumberOfBits As Variant) As String
Dec2Bin = ""
Do While DecimalIn <> 0
Dec2Bin = Trim$(Str$(DecimalIn Mod 2)) & Dec2Bin
DecimalIn = DecimalIn \ 2
Loop
If Not IsMissing(NumberOfBits) Then
If Len(Dec2Bin) > NumberOfBits Then
Dec2Bin = "Error - Number exceeds specified bit size"
Else
Dec2Bin = Right$(String$(NumberOfBits, _
"0") & Dec2Bin, NumberOfBits)
End If
End If
End Function
--------------------------
I think that code came from Karl Peterson's website:
http://vb.mvps.org/
It's worth a visit. Among other things he has a package
of sample code for all sorts of variations on bit/byte
manipulation:
http://vb.mvps.org/samples/project.asp?id=Twiddle
....
Does anyone know? pls help tks!message 1,
"Howk013" wrote:
Hi rick,
hmm..ok,
for example:
Bit 0-6 reserved for message identifier , so if the user keyed in
itwhich they get to choose from combo box, the code must be able to encode
6bitusing 6bit-ascii to get an output of "1" ( because 000 001 is 1 in 6bit
ascii conversion)
Subsequently,if bit lengths allocated are higher than 6 bits, they are
broken down into blocks of 6, to encode and get the output according to
functiontable
The subsequent bits are used for other functions like latitudes and
longitudes etc. Which requires more than 6bits
so assuming 0-6 is used , and bit 7 ( is a "1") represent another
iswhich is a switch, and bit 8 (is a "0") represent another function that
thisalso another switch, while 9-38 indicates the number of an object (in
, itcase, user input "127" which is 0000 0000 0000 0000 0000 0001 1111 11 )
basically)will look like this
000 001 ---------------------> 1
1(bit 7)0(bit 8)0 000---------> P
000 000-----------------------> 0
000 000-----------------------> 0
000 000-----------------------> 0
011 111-----------------------> O
11x xxx and so on
the right hand side represents the output i would like to obtain after
running the code. (which is conversion from the 6bit ascii table
characters)?
Once again, thank you all for prompt replies!
"Rick Rothstein (MVP - VB)" wrote:
When the user input all the data of the 168bits
Exactly what is the user inputting (I presume it is a string of
Show us an example of a typical user input.
Rick
.
- Follow-Ups:
- Re: How do i change numerics into binary numbers?
- From: Rick Rothstein \(MVP - VB\)
- Re: How do i change numerics into binary numbers?
- From: Howk013
- Re: How do i change numerics into binary numbers?
- References:
- Re: How do i change numerics into binary numbers?
- From: Rick Rothstein \(MVP - VB\)
- Re: How do i change numerics into binary numbers?
- Prev by Date: Re: On top in XP
- Next by Date: Re: My Findings - VB6 Apps on Vista
- Previous by thread: Re: How do i change numerics into binary numbers?
- Next by thread: Re: How do i change numerics into binary numbers?
- Index(es):
Relevant Pages
|
Loading