Results 1 to 6 of 6

Thread: How to convert an integer into array of bytes?{RESOLVED}

  1. #1

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    How to convert an integer into array of bytes?{RESOLVED}

    anyone?
    Last edited by nemaroller; May 8th, 2003 at 02:14 PM.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Well first the integer has to goto a class, and learn about being an array of bytes. Should it choose to convert, it will need to attend a series of additional classes. Having passed all of the classes, one final step must be performed. In an act of true faith it must then surrender all its worldy goods and become a member of its new caste. But the sacrifice must be voluntary and complete. Then and only then shall it find true harmony and peace as an array of bytes....



    Sorry nema-- it's been one of those kinds of days.

    does CByte() exist? That's the only thing I can think of off the top of my head....
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Lol, thats ok Techgnome, enjoyed the creativity....

    I found my answer... it calls itself the BitConverter class.... and transforms any basetype into an array of bytes...

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    shaweet! You got a link to that? I coulda used it a while back.... I'll have to add it to my bag o' trix.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Its in the framework...

    Dim G as BitConverter


    although I still haven't figured out how to assign the bytes from the BitConverter to another byte array...
    VB Code:
    1. Dim r As Integer = 32
    2.         Dim c As Byte()
    3.         Dim g As BitConverter
    4.  
    5.  
    6.         g.GetBytes(r)
    7.         r = 0
    8.         r = g.ToInt32(c, 0)
    9.         MsgBox(r.ToString)

  6. #6

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    NEvermind, got it resolved now:
    VB Code:
    1. Dim r As Integer = 32
    2.         Dim g As BitConverter
    3.         Dim c() As Byte
    4.  
    5.         c = g.GetBytes(r)
    6.  
    7.         r = 0
    8.         r = g.ToInt32(c, 0)
    9.         MsgBox(r.ToString)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width