Long to array of bytes

C

Chris Wilmot

Dim MyLong As Long = 55695542

Dim msg As Byte() = System.Text.Encoding.ASCII.GetBytes(MyLong)



CW
 
J

Jan

Thank you, but I need convert into binary (memory) form.
I need only 4 bytes in result.

ex: long value 55695542 -->

arr(0) == &HB6
arr(1) == &HD8
arr(2) == &H51
arr(3) == &H03

Please, can you give me advise

Thank you
 
J

Jeffrey Tan[MSFT]

Hi Jan,

I think you can use Shift Operators to get certain bit.

HTH.
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Jan" <[email protected]>
| Sender: "Jan" <[email protected]>
| References: <[email protected]>
<#[email protected]>
| Subject: Re: Long to array of bytes
| Date: Fri, 22 Aug 2003 01:48:02 -0700
| Lines: 32
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcNoihjXyOTjNSzbSgu/vIw5YOe8rA==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.languages.vb
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:129629
| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| Thank you, but I need convert into binary (memory) form.
| I need only 4 bytes in result.
|
| ex: long value 55695542 -->
|
| arr(0) == &HB6
| arr(1) == &HD8
| arr(2) == &H51
| arr(3) == &H03
|
| Please, can you give me advise
|
| Thank you
|
| >-----Original Message-----
| >Dim MyLong As Long = 55695542
| >
| >Dim msg As Byte() = System.Text.Encoding.ASCII.GetBytes
| (MyLong)
| >
| >
| >
| >CW
| >
| >| >> How can I convert Long value to array of bytes?
| >>
| >
| >
| >.
| >
|
 
H

Herfried K. Wagner [MVP]

Hello,

Jan said:
How can I convert Long value to array of bytes?

\\\
Dim abyt() As Byte = BitConverter.GetBytes(CLng(12345))
///

HTH,
Herfried K. Wagner
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top