7 Years
Discussion Span
Last Post by Unhnd_Exception
Dim DecimalNumber As Double = 85.78

       'an easy way is to use the BitConverter Class
       Dim DecimalBytes() As Byte = BitConverter.GetBytes(CDbl(DecimalNumber))
       'this will now contain 16 bytes

       'another way is to use the BinaryWriter
       Dim mStream As New System.IO.MemoryStream
       Dim bWriter As New System.IO.BinaryWriter(mStream)


       Dim TheOtherDecimalBytes() As Byte = mStream.ToArray
       'This will contain the 16 bytes.  The same as the Decimal Bytes()

       'To Convert the bytes back to decimal
       Dim DecimalFromBitConverter As Double = BitConverter.ToDouble(DecimalBytes, 0)

        'Using the Binary Reader
        mStream = New MemoryStream(TheOtherDecimalBytes)
        Dim bReader As New BinaryReader(mStream)

        Dim DecimalFromBinaryReader As Double = bReader.ReadDouble

Just make sure to mark the thread as solved when when your situation is solved.

And I just noticed the VB6 in your post.

Don't post VB6 Questions here.

I have just wasted time posting this. It will not help you. You would be better off finding information on VB6 in the Cobol or Fortran forums.

Edited by Unhnd_Exception: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.