help..i'm stuck here

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi guys,
May i know how to declare a string of binary data and pass it to the method?
For example, int a[]={10010001120420052314}
is it correct?
and if i have receive the binary data, may i know how to separate them and
store each of them inside a variable such as int cust_id?is it possible? For
example, the first four bits is the customer id, the second four bits is the
call id and third 8 bits is the date and the remaining is the time..

thanks in advance..
 
? Your example isn't a binary string to begin with... 2, 3, 4, 5 aren't
binary digits...

Are you trying to pass this as a string? If so, what's the advantage to
converting it to binary first? The only advantage to converting your items
and "packing" them into binary format would be the space savings and faster
speed of transmission over the wire. If you're converting them to a String
of "1" and "0" characters, you're completely defeating any space or speed
enhancements.
 
oh..ya.i wan to pass it as a string....then separate them according to the
attributes...may know how to do it?

Michael C# said:
? Your example isn't a binary string to begin with... 2, 3, 4, 5 aren't
binary digits...

Are you trying to pass this as a string? If so, what's the advantage to
converting it to binary first? The only advantage to converting your items
and "packing" them into binary format would be the space savings and faster
speed of transmission over the wire. If you're converting them to a String
of "1" and "0" characters, you're completely defeating any space or speed
enhancements.

alyssa said:
Hi guys,
May i know how to declare a string of binary data and pass it to the
method?
For example, int a[]={10010001120420052314}
is it correct?
and if i have receive the binary data, may i know how to separate them and
store each of them inside a variable such as int cust_id?is it possible?
For
example, the first four bits is the customer id, the second four bits is
the
call id and third 8 bits is the date and the remaining is the time..

thanks in advance..
 
This will do what you're asking. It will convert an Integer to a Binary
String representation:

Function ToBin(ByVal i As Integer) As String
Dim BinaryDigits() As String = {"0000", "0001", "0010", "0011", _
"0100", "0101", "0110", "0111", _
"1000", "1001", "1010", "1011", _
"1100", "1101", "1110", "1111"}
Dim HexDigits As String = "0123456789abcdef"
Dim sb As New System.Text.StringBuilder(256)
Dim strHex As String = Hex(i).ToLower()
For Each c As Char In strHex
sb.Append(BinaryDigits(HexDigits.IndexOf(c)))
Next
Return (sb.ToString())
End Function

Other than for Display Purposes (assuming you need to view an integer on
your screen in Binary format), there is no added value to this function.

alyssa said:
oh..ya.i wan to pass it as a string....then separate them according to the
attributes...may know how to do it?

Michael C# said:
? Your example isn't a binary string to begin with... 2, 3, 4, 5 aren't
binary digits...

Are you trying to pass this as a string? If so, what's the advantage to
converting it to binary first? The only advantage to converting your
items
and "packing" them into binary format would be the space savings and
faster
speed of transmission over the wire. If you're converting them to a
String
of "1" and "0" characters, you're completely defeating any space or speed
enhancements.

alyssa said:
Hi guys,
May i know how to declare a string of binary data and pass it to the
method?
For example, int a[]={10010001120420052314}
is it correct?
and if i have receive the binary data, may i know how to separate them
and
store each of them inside a variable such as int cust_id?is it
possible?
For
example, the first four bits is the customer id, the second four bits
is
the
call id and third 8 bits is the date and the remaining is the time..

thanks in advance..
 
Back
Top