?
Solved

From Integer to Bytes

Posted on 2002-06-16
5
Medium Priority
?
211 Views
Last Modified: 2012-06-22
How can I get the 2 bytes values from an Interger?
0
Comment
Question by:DImirC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 44

Accepted Solution

by:
bruintje earned 400 total points
ID: 7082244
Hi DImirC,

maybe this snippet from Harvey Triana will help

By example (buil in memory an Integer):

'//Integer bytes
Private Type udtIntBytes
    B1 As Byte
    B2 As Byte
End Type

'//Integer
Private Type udtInt
    n As Integer
End Type

Private Sub Test()
    Dim MyInt As udtInt
    Dim b     As udtIntBytes

    MyInt.n = 2001

    LSet b = MyInt
End Sub

b contain the two bytes of Integer.


HAGD:O)Bruintje
0
 

Author Comment

by:DImirC
ID: 7082527
Thanks,

Do you know how to make the invers process also?  from bytes to Integer?
0
 

Expert Comment

by:HobbitHouse
ID: 7082535
   byte1 = CInt((CLng(int1) And &HFF00) \ 256)
    byte2 = int1 And 255
0
 

Expert Comment

by:HobbitHouse
ID: 7082538
inverse process is

int1 = byte2 + (byte1 * 256)
0
 
LVL 44

Expert Comment

by:bruintje
ID: 7082541
well Hobbithouse was way faster
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month8 days, 1 hour left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question