Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Convert String To Binary

Hi, I was thinking to make an application, which contains two text box's and a command button. When you type something in the first text box and click the command button, the program should convert the text and type the output into the second text box. Is this possible or not, if it is possible I really apreciate if someone gives me the answer, thank you

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Convert String To Binary
just like the topic,thanks

Convert Binary String To Hex
Hi, I am writing a program that takes data form a sensor and passes it through a USB comm port, displaying it on the screen. It will have real time updated graphs at some point, but that is getting a little ahead of myself.

The data is a 14 byte Hex string which looks a little like this;

AA 55 01 02 3E F9 00 00 00 00 00 C7 55 AA

The problem is that the sensor is transmitting this hex string as binary. I have tryed to convert the binary to hex but with no joy. The only method I can get to work is to convert the binary to Ascii, and then to hex using the following code;

Dim InBuff As String
Dim Data As String

Private Sub MSComm1_OnComm()

If MSComm1.CommEvent = comEvReceive Then
InBuff = Asc(MSComm1.Input)
End If

Data = Hex(InBuff)

Text1.Text = Data


This works to an extent, however the text box will only display one byte at a time and I need the whole string displayed. Is there anyway to convert the whole string at the same time, or if not, how do I string all the individual bytes together to form the original string?

Thank you for your time and help,

Stuart Mills.

Convert Hex String To Binary File
Is there any easy way to convert a hex string into a binary file?

Convert Binary String To A Double
I need to convert a Binary String to a Double using VB 6.0 sp5.
This string is read from the Winsock control from a device on the network.

Here is the Binary String

Here is the Hex values
184 162 206 97 115 52 226 64

Does anyone know a function to covert this string.
Can I use a User defined type to do the conversion.


Convert A Binary File To Ascii String
Dear All:

I have a problem on converting a binary file to a Ascii String.
The following is a sub to convert an input binary String to ascii string but I found that
it does not working
Can someone point out where did I do wrong???

Thanks in advance

public Sub Bin2Asc(strBin as string, strAsc as string)
Dim lLen as Long, i as Long, strBin2 as string
lLen = len(strBin)
strAsc = ""
for i = 1 to lLen
Dim strTmp as string
Dim btByte as Byte
strTmp = Hex(Asc(mid$(strBin, i, 1)))
If len(strTmp) < 2 then
strTmp = "0" & strTmp
If len(strTmp) = 4 then
lLen = lLen - 1
End If
strAsc = strAsc + strTmp
If i = lLen then
Exit for
End If
next i
End Sub

Convert String To Binary Format And Vice Versa
hi friends,

can we convert binary format to string and string format to binary format?
if yes can u help me how to do it.


Convert To Binary
Hi guys,

I am a newbie in VB. May I know how to convert a string into HEX and binary form?

How To Convert *.wav To Binary
please help me to convert *.wav to binary, and from that binary convert to a sound which like the sound in *.wav file. I mean that i have a *.wav file and i turn it to a binary file and from that binary file turn it to a sound, so i don't need the *.wav at all, i also mean from that binary file my programe can speak a sound like the *.wav sound. if you have source code like this you can let me know about it. thanks

Convert Binary To Hex
How to do this without getting overflow errors?

I need to convert 111111111111111111111111111

to hex

That is all


Convert To Binary
Anyone know how to return a binary value
from a decimal in vb?
Im writing a small prog to determine Network ID's
for Classless Inter-Domain Routing.

How To Convert Into Binary
if i'm input a text as text1.text
when i click on the buttom i will get the binary of text1.text to text2.text

can any one help me out..

thx jimfi

Edited by - jimfi on 8/5/2004 8:53:54 AM

How To Convert *.wav To Binary?
please help me to convert *.wav to binary, and from that binary convert to a sound which like the sound in *.wav fileI mean that i have a *.wav file and i turn it to a binary file and from that binary file turn it to a sound, so i don't need the *.wav , i also mean from that binary file my programe can speak a sound like the *.wav sound. if you have source code like this you can let me know about it. thanks

Convert Binary To Hex And Dec
an easy way to convert binary to dec and hex

Convert Hex To Binary?
I need help on how to convert hex to binary in VB 6, thank you

Convert DC Into Binary Data
i want to convert my obtained DC in to binary data so that i could send it through sockets usind UDP.I know the GetPixel way...but that will consume some time.If i could convert the entire DC into binary in a single stretch the app would have been more fast.
Thanks in advance.

Convert Int To Binary And Collect Each Bit Value
May I know what is the code to convert an unsigned integer (0 to 65535) to Binary? Besides, how do I collect each bit value from the converted binary?
I am using VBA to run this.

Example case: Let's say I want to convert a random value 23767 to binary which the result is 101110011010111, then I need the 12th bit value (in red color) to be displayed or used.

Please help, Thank you very much. ~

How To Convert Raw Binary Into Ascii Hex
i need to know how to convert raw binary into ascii hex, i searched around but couldnt find anything on it. anyone know?

Convert Binary To A Date
Anyone know how I would turn this 1021514912 (binary) into a date?

Convert IP Address To Binary
How can I convert IP address to binary? Is there a function in VB that can do that?


"Great Ideas need Landing Gears as well as Wings"

Convert Massage To Binary
my project is to make sender and receiver with winsock but the message wich send to receiver have to convert to binary, and receiver will translate the binary to original message. looks like my last question, would you tell me how to create the converter component for my program ?


Convert Integer To Binary Hex Value
I have a variable which is for sake of argument the Size of a File in Bytes. The value is an integer

I wish to convert this value into a binary string so that I can transmit it via the ethernet winsock control.
Basically I want to convert the whole number using something like the CHR function. However I also need the number to be padded to 'n' bytes....


FileSize = 123456
n = 6

DataToSend = convert(filesize,n) ' <-- this is the function Im stuck with

The result would be DataToSend = 0x 01E240

Any ideas / suggestions?



Convert Hexa To Binary

What I need to make a conversion from a hexa char to a binary code, like this:

3F to 111111


20 to 100000


Convert Decimal To Binary??
Dumb question... is there a built in function to convert decimal numbers to binary?

ie. convert 164 to 10100100

Or am I going to have to write a function to do this?

lol, something I never thought I'd need to do.

Convert Decimal To Binary
Hello all,

I have just written a function to convert a decimal number into binary. The function works fine with just one problem, I need the number in eight bit binary format.

For example my code will convert the number ten into 1010. I need it to convert it so it reads 00001010. This is my current code;

Public Function inttobin(ByVal decnum As Long) As String
Dim binstring As Integer
Do While decnum <> 0
binstring = decnum Mod 2
inttobin = binstring & inttobin
decnum = Int(decnum / 2)
End Function
The only way I could think of achieving this was like this;

Public Function inttobin(ByVal decnum As Long) As String
Dim binstring As Integer

Do While decnum <> 0
binstring = decnum Mod 2
inttobin = binstring & inttobin
decnum = Int(decnum / 2)

Do While Len(inttobin) <> 8
inttobin = "0" & inttobin

End Function
but this seems a like a bad way to do it. Is there anyway I can make sure that the inttobin string is always 8 bits with any additional buffered bits being 0?

Convert Picture To Binary
Hello Gurus...

What I am trying to do;
1-Load picture (jepg) into Picture1 object.
2-Convert loaded picture in Picture1 to binary format.
3-Save that binary into database.

My problem;
How to convert picture in Picture1 to binary?


Convert A Char To Binary
Am trying to convert a char into binary
sending the char to function bin in ascii form
is the conversion function correct

VB Code:
Public Function bin(ByVal a As Integer) Dim j, k As IntegerDim str As String str = ""i = 0j = ak = 0'MsgBox " value recieved " & jWhile j <> 0k = j Mod 2str = str & kj = j / 2'MsgBox jWend   bin = strEnd Function

Convert Ascii To Binary
Hi all.
I have a bit of a problem. I am getting a value from an OCX and it is in ascii. How can I convert the string so that it shows the binary representation of these values?

I.E. I get the value "Hi" "H" is 072 ascii and "i" is 105 ascii.

Then turning and converting those values to binary so that I get

"010010001101001" the binary equivilant.

Any help would be GREATLY appreciated

Convert Binary To ASCII
I'd like to convert binary code into ASCII. Does anyone have any code that could pull that off?? Thanx in advance!

Easy Way To Convert To Binary?
is there a built in fuction to return a number in binary?!

How To Convert Ascii Into Binary
I want to know that how we can convert our ascii text into binary one.

Convert Binary To Decimal In VB
I've been looking for a way to do this for about two weeks now. Searching Google, Yahoo and even these forums. My question is. How can you convert Binary to Decimal? The app I am writing needs to take a binary number that someone enters into a text box, convert it to decimal and output that to another text box. This would be done with a button click event of course. I've got everything together except that part. I'm using Visual Studio 2005. Any help would be appreciated.

Convert Keyascii To Binary
hi all,

I have a program that when a key is pressed, it stores the keyascii of that key inot a varible. What i want is for that keyascii number(lets say 103) to binary and add the binary form to a list box.

any help would be greatly appreaciated, Thanks.

Convert StringSID To Binary SID
Hi, I am looking for a way of converting a StringSID to a binary SID using Visual Basic. The code to go from a binary SID to a String SID is easily available, and I can find a C++ function to do this, but I can't seem to find the VB equivalent.


How To Convert Decimal To Binary
I want to convert decimal to binary Help me please

Convert Binary To Single

I am trying to get a value into an Excel spreadsheet via DDE. The raw data is a 32 bit float number, but the cell interprets the value as an integer.

Example bit pattern : 0100 0001 1011 1010 1100 1101 0000 0000

Wanted value : 23.34375......

Shown value : 1102761216

Is there any function to get the correct interpretation?

Convert Binary To Ascii
I am not familiar with binary file access, so forgive me if this is obvious:

When opening and reading a binary file, how do you convert it to Ascii?

How Do I Convert Binary To Decimal ?
I want to convert Binary to decimal with VB , can soemone pleasssssssssse help me , thanx a lot !

Convert 4byte Binary Number
I am reading/writing stock quotes from a random access file, but the output when I print it is in scientific format. I cannot find in the help or my manual how to convert back to a single precision number. Please help.

Convert Any File To Binary Information ???
Is there a way to read any file "byte-by-byte" (or bit...wotever) and write the 0s and 1s into a text file???

...... and vise versa?

Thanks in advance!

Need To Convert Integer To Binary And Display It
ok here's the problem.. Let's say I have a number 7.. There is 6 circles in the form and i need to light up the 3 circles because binary equivalent of 7 is 000111.. Another example would be the number 8 which is 001000 in binary therefore i have to light up the 4th circle.. If that's not enough another example would be the number 12, its binary would be 001100, i have to light up the 3rd and 4th circle.. i have no problem lighting them up, the problem is how how to convert. any ideas?... thanks a lot..

Convert A Image Into Binary Code
how can i convert a image into binary code

How To Convert Binary To Decimel And Back?

how to convert from binary to decimel? I found some software for that in PSC
but it was limited in the number of digits...
I need a code that will can convert very large numbers, with even 100
of digits...

can anyone help??


A Way To Convert Characters To Their Binary Values?

pls tell me a way to convert characters to their binary values.


Convert Binary To Orginal File
Hey all,

Does anyone have a clue how to convert binary data back to it's orginal format?

For example i have binary data which was once a picture how do i get it back??


How To Convert Numbers To Binary Strings
What I have to do is to create a list like this
A - B - C - AB - AC - BC - ABC

The user enter a number say 3
A - B - C

The computer must create
AB - AC - BC and ABC

I was going to do it by using binary code.

example: user enters 3
number in binary 2^3-1 is 7 >>> 7 possible combinations
A - etc... There are seven, see above.

If I count in binary from 001 (1) to 111 (7) i can list
100, 010, 001, 110, 101, 011, 111
A,B,or C if a 1 is in the code, giving me all of the above combinations, wha la... But. How?

I was going to do it by converting the binary number to a string and then using an if statement to step through the string one letter at a time and list the appopriate letters.
But, How do I get this binary number to print out???? I cant find a simple binary number generator....


Convert Ascii To Binary( 0[zeros] And 1[ones])
Most of you should know what binary is! I don't know how to do this:
convert ASCII characters to binary any help?


Convert Binary To Signed Integer Value
Hi all,
I am working with a binary file. The byte at position 16 of the binary file has the number of records in the file in a binary format.

So for example, if the binary representation of byte 16 in the file is 11111100, this would translate to 790780 records. 00011101 is equal to 29 records.

How do I know the equivalent? As of now I can open each file and go to the end of the file and that gives me the number of records. It is a tedious job becuase there are days that I need to find the count for upto 500 files.

How do I convert the binary representation of 11111100 to 790780 in vb.

Is this possible?

Thanks for any help.


How To Convert IP Address Binary To Decimal...
Hi everyone...

I wrote an IP address converter program a while back, and I was able to write the math to convert from decimal to binary, but not the reverse. So I ended up using a database for the reverse conversion. Does any math guru know the math to convert the IP address binary to decimal?

e.g. 01111111.00000000.00000000.00000001 to

Thanks in advance...


Edited by - D-Race on 5/5/2005 3:56:43 AM

Suggest How To Convert Decimal To Binary
Please suggest me how to convert decimals to binary in VB.




Copyright 2005-08, All rights reserved