473,396 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to make conversion?

32
can make conversion in the byte to binary??

thanks
May 24 '07 #1
3 1005
Killer42
8,435 Expert 8TB
can make conversion in the byte to binary??
Perhaps this is what you're looking for? It's written in VB6, but may also work in later versions.

Expand|Select|Wrap|Line Numbers
  1. Public Function Bin(ByVal ByteValue As Byte) As String
  2.   Dim I As Long, BitValue As Long, BitWeight As Long
  3.   For I = 0 To 7
  4.     BitWeight = 2 ^ (7 - I)
  5.     BitValue = ByteValue \ BitWeight
  6.     Bin = Bin & Format(BitValue)
  7.     ByteValue = ByteValue - BitValue * BitWeight
  8.   Next
  9. End Function
May 24 '07 #2
dyc
32
Perhaps this is what you're looking for? It's written in VB6, but may also work in later versions.

Expand|Select|Wrap|Line Numbers
  1. Public Function Bin(ByVal ByteValue As Byte) As String
  2.   Dim I As Long, BitValue As Long, BitWeight As Long
  3.   For I = 0 To 7
  4.     BitWeight = 2 ^ (7 - I)
  5.     BitValue = ByteValue \ BitWeight
  6.     Bin = Bin & Format(BitValue)
  7.     ByteValue = ByteValue - BitValue * BitWeight
  8.   Next
  9. End Function
Erm...I quite not really understand about the code..Can u pls explain it ?
thanks ya...
Jun 7 '07 #3
Killer42
8,435 Expert 8TB
Erm...I quite not really understand about the code..Can u pls explain it ?
thanks ya...
Well, since it's a function, you don't necessarily have to understand it. That's the beauty of a function - it can be used as a "black box" without worrying about the "innards".

It takes in a byte value, and returns the string of "0" and "1" indicating the binary value of the byte. Try passing values to it from the immediate window. For example...
Print Bin(38)
If this isn't what you were after, then please explain further.
Jun 7 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Stub | last post by:
Docs says that "The compiler does not use an explicit constructor to implement an implied conversion of types. It's purpose is reserved explicitly for construction." I put up code of three cases...
7
by: Kapt. Boogschutter | last post by:
I'm trying to create a function that has at least 1 Argument but can also contain any number of Arguments (except 0 because my function would have no meaning for 0 argument). The arguments...
4
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is...
11
by: Steve Gough | last post by:
Could anyone please help me to understand what is happening here? The commented line produces an error, which is what I expected given that there is no conversion defined from type double to type...
19
by: zzw8206262001 | last post by:
Hi,I find a way to make javescript more like c++ or pyhon There is the sample code: function Father(self) //every contructor may have "self" argument { self=self?self:this; ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.