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




Binary Ascii Code


Hi there!
A few weeks ago I asked for your help and got it to develop the function below. The function is supposed to transform a string into binary ascii and add an eight 0 in front. Problem solved. The problem is that this didn't work with the device I'm trying to program, so after trying to fix other things I thought might cause the problem, I decided that maybe I should try to put the 0 at the end, instead of the front. Well... I tried some things, but I'm getting a messed up output in the end. So again I ask for help.
Thank you!



Code:

Private Function ASCIIBin(sString As String) As String

Dim iPos As Integer, iAsc As Integer, iTest As Integer, iPower As Integer

For iPos = 1 To Len(sString)
iAsc = Asc(Mid$(sString, iPos, 1))
For iPower = 7 To 0 Step -1
iTest = 2 ^ iPower
If iTest <= iAsc Then
ASCIIBin = ASCIIBin & "1"
iAsc = iAsc - iTest
Else
ASCIIBin = ASCIIBin & "0"
End If
Next iPower
iPower = 0
ASCIIBin = ASCIIBin ' & " "
Next iPos

End Function




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Convert Binary Code To Ascii Code
Does anyone know how to convert binary file to text file

Binary ASCII Hex Conversions And Reading From Binary File
A coworker has dumped a task off on me and I am not sure were to even look for what I need. First I need to read a binary file. then I need to take this information and display the information in Hex(in a text box). For my own use I would like to disply the binary information in a text box (as 0's and 1's) and the decimal value of the binary information.

Here is copy of my program, currently messy & clunky and in need of streamlining, but I figure other people might whant the code & it should make a good starting point for some one elses program
Thanks for the Help every one!!!!



Edited by - NcNghtStkr on 8/23/2005 7:13:17 PM

Binary To Ascii
Me again, how do you open a binary file , convert it to ascii and put that in a txtbox? I have tried, at the top I can read my location but then its just unreadable data, it doesnt look like binary or hex to me;


Quote:




X v (gCQ @ l*o MIBOOK +gCN @ /3h WARBOOK O e4 @ -lN2 -gCG




is that encrypted?

Binary To Ascii
Is there a possibility to convert Binary file into ASCII file using VB?

Thank you.

Ascii Into Binary
Is thier a simple command in VB to change a string of Ascii charaters into a string of thier Binary conterparts? I could do it with a long If statment in a loop, but you guys are quite clever so I thought I'd ask anyway.

Cheers
~ichar

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?

ASCII File To Binary
Hello all,

I want to convert an Ascii file to binary. Is it possible thro' vb??

Some details are as follows:
I am using a library Roper Scientific Winx/32 automation for grabing images from a camera. Now this supports four formats.i.e Ascii,tif8,tiff,spe. I'm saving this image as ascii. This is because resolution changes using tif8 ot tiff format. And spe format is not detected through Matlab in which i want to finally read this image.This is it. So i think somehow i will be able to convert this ascii file to binary so that i can read it through matlab.So can u ppl help me in this?

Thanks & Regards

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

ASCII To Binary Conversion
Which function in VB accepts ASCII numbers (or string character) and returns its Binary equivalent.

e.g. I should pass it 65 (ascii of A), it should return 01000001, etc.

And which one does the opposite, I pass it binary and it should return its ascii.

Thanks,

Pradeep

Converting Ascii To Binary
Is it possible to convert to binary and from binary?

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!

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

Binary Data To ASCII
Hello ppl,

I want to convert binary data (found in a exe file eg) to ASCII to send it via the internet in my prog.

First I want to open the binary file (eg HelloWorld.exe) and convert the contents to a ASCII file (eg HelloWorld.txt). Now I can open this file and send to with my winsock prog.

The other side should get the ASCII and convert it back to the binary exe file.

Now I know how to send etc, but now the converting problem...

Please help me out here.

Converting Ascii To Binary
any body knows how to convert ascii code to binary code?

thks for helping in advance

Binary --&gt; Ascii Chars Help
This cuts off the end character of the text it's processing. How do I fix this?
Code:Private Sub Command1_Click()
Dim txtarray() As String
txt = Text1.Text
txtarray = Split(txt, " ")

For i = 0 To UBound(txtarray)
    Select Case txtarray(i)
    Case "00000000"
        asctxt = "(NUL)"
        asctxt = "{"
    Case "01111101"
        asctxt = "}"
    Case "01111100"
        asctxt = "/"
    Case "01111110"
        asctxt = "~"
    Case "01111111"
        asctxt = "D"
    Case Else
        asctxt = " (ERR)"
    End Select
    
    endtext = endtext & asctxt
Next
Text1.Text = endtext
End Sub
 



Edited by - SamuelDravis on 11/18/2003 9:30:04 AM

Find If Ascii Or Binary
Hi,

I am trying to read a file. but before reading it want to determine whether that file is ascii or binary file.

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 To Determine Whether File Is Ascii Or Binary
Hi there
Any idea how to make a VB program able to determine from a filename whether the file is ascii or binary?

Converting A Binary File To Ascii
I am creating a tool in VB to search HTML and PDF files and for selected strings. Comparing strings in the HTML file was ok as HTML is an ascii file and I only had to implement some code to remove the tags.

The problem I am having is comparing strings in the PDF file as they are binary files. Is there a way of using VB to convert the file nto ascii prior to comparing the strings?

I hope that makes sense.

Thanks

Saving Files ASCII Or BINARY??
Hello to All i want to save the Actual TExt files in less space with out compressing them for retriving the data more fast. any one please advise me regarding these techniques and any links if any of you know....

Thanks
Sreekanth Doppalapudi
sreekanthd@onebox.com

Ebcdic Ascii Hex Dec Oct Chr Binary Unicode
Recently, I am very interest in understanding more about these different formats:

ebcdic
ascii
hex
dec
oct
chr
Binary
Unicode

-Are there more?
-The ones that I have listed, what use do they have and when would you use it? I know some of them already.
-Why would you convert from one format to another?

I found this but really want to understand the correlations:
http://www.lookuptables.com/ebcdic_scancodes.php

I learned EBCDIC about 10 years ago but can't remember the purpose it serves for today.

Thank You

Determine If A File Is Binary Or ASCII
Is there any easy way to determine if a file is binary or ASCII?

Conversion From Ascii To Binary Format
hello ,

is there any direct function of converting ascii values to binary format.

thanks
nice day
jyothi

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?
THANKS!

------------------
DiGiTaIErRoR

On Converting An ASCII String To Binary Digits
I'm trying to find out first of all if this has been done before and if i'm waisting my time by doing it again, and if not how best to go about doing it.

What I'm trying to do is make a simple form one button one text box (or rich text box) and one label. input text into text box hit button and text in box is converted into it's binary equivelant. not converting numbers into binary but the binary representation of its ASCII code (N=01001110, n=01101110, etc.) any help would be appreciated.

Read Hex/Binary String From Database As Ascii
Hello Everyone,

I'm connecting to a Microsoft SQL Database. One of the fields I need to read is a column of type "Binary" in SQL Server. Here, for instance, is a trace of an INSERT to this database.

INSERT INTO...... TABLE ... "CFG01",@P2 .... @P2 varbinary(100) ..... 0x593230303730343138303031202020204C02004E3C00592020202020202020202020 2020202020202020202020202020202020202020202020202020202020202020202020 20202020202020202020202020202020202020202020202020202020202020

(Relevant Parts Included)...

And what that 'Says' in ASCII is "Y20070418001................."
Y=59
2=32
0=30
0=30
7=37
0=30
4=34
1=31
8=38
0=30
0=30
1=31
....

So... Anyone know how to 'Read' That string into ASCII Characters? When I do a simple "SELECT CFG01 FROM TABLE", I get, in VB a string that looks like this...
"????????<?"... Not exactly what I need.

ANY Help greatly appreciated!

THANK YOU
Ben

Convert Binary Value To ASCII (NEVER MIND, RESOLVED))
What is an easy way for that ?




Thank ya all!

Reading Binary File Created In C (AScii)
Heyas,

I am racking my brain over this and hopefully some kind soul can put me out of my misery.

I have a binary file which stores data so:

typedef
{
char key[7];
char desc[20];
short supp_code;
long free_stock;
short min_stock;
char date[7];
float price;
}RECORD DATA;

Now whatever I do I cannot read this from VB without an error somewhere.

The closest I get is

Public Type StockRecord
key As String * 6
NC1 As String * 1
desc As String * 19
NC2 As String * 1
supp_code As Byte 'short
NB1 As Byte
free_stock As Integer 'long
NB2 As Byte
NB3 As Byte
minstock As Byte 'short
NB4 As Byte
YY As String * 2
MM As String * 2
DD As String * 2
NC4 As String * 1
price As Single 'float
End Type


I trust I am being very stupid somewhere - but bear with me.

Where NC stores Null chars and NB stores what seem to be bytes in the file that are not compatible with ASCII wheres as ofcourse in VB we work in UNI.

C Strings are ofcourse NULL terminated hence after each string I am reading the null and this is simply not used.

The above will give me everything except the minstock goes wrong for some records and right for others. Obviously Im doing something wrong with reading and discarding individual bytes and am probably barking up the wrong tree completely.

Can someone please either tell me the correct way to read a C data type short or correct my VB UDT / advise how I should be doing this?

Man thanks for any help

CandyMan

Reading Binary File Created In C (AScii)
Heyas,

I am racking my brain over this and hopefully some kind soul can put me out of my misery.

I have a binary file which uses a structure:

typedef
{

What Is The Best Way To Transfer (ascii && Binary) Data Between Two Processes?
I need to transfer string data - both ascii and binary - between to processes. i'm thinking about using the windows message system (PostMessage ....), but unsure whether this could handle binary data and what the maximum string length is.

are there any other possibilities like using something activex related?

Thanks for your advice!
Felix

Detecting File Type? ASCII Or Binary?
Hi All,

I am trying to create an application with VB6 that can detect file type while recursing a folder structure and if it is an ASCII file, strip the ctrl-M's from the file for inclusion in a Windows environment created package for installation on a UNIX environment.

We have a NT script running now that goes through a large list of file extensions and for each one runs the DOS2UNIX utility to strip the Windows type line endings (ctrl-M's), but I want ot make it more efficient by not having to know what extensions are needed and recursively go through each folder of a structure and detect what type of file is listed and run the stripping of ctrl-M's if it is an ASCII file.

Any ideas on the detection of file type?

Thank you in advance,
John

Find String In Files (ASCII And Binary)
Hello,

How can i search inside all the files available in the Disk like Windows Find Function works.

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) &lt; 2 then
strTmp = "0" & strTmp
else
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

Give Code In VB For Binary Conv. Like 1010 Is Binary Of 10
Please give the code of Binary conversion in VB .

Global Events For Keyboard SCAN CODE && ASCII CODE Event Trapping?
OK, don't be mad at me, if this is a stupid question, but I'm quite new to VB, so here's my Q:
Is there any global event (not KeyUp/KeyDown/KeyPress) to trap keyboard keypresses with SCAN codes? It is very important to have the exact scan code. I want to use an API function to simulate the pressed keys on an other machine, and I need to have the scan code. By the way, API function calls won't do it for me, I need an EVENT! (I don't want to call functions over and over again e.g. in a timer event. This is too -slow-)
So if anyone out there can help me, please do!
You won't regret it!

Thanks to all....

Generate An Ascii Code From Vb Code And Vise Versa
hello,
i working in a project where i should read ascii code using the vb to generate the result on excel and vise versa, generate the ascii code using vb

any one have already did this?

thanks for the help

ASCII Code
does anyone know what the ASCII code for spacebar and enter is?
Thanks

ASCII Code
I'm trying to get the application to display the word that the user enters in a text box in ASCII .. but it's only displaying the first letter in the word .. how can I get it to display each character?

Is There An Ascii Code For Nothing?
ie if

sTest= ""
msgbox chr(sTest)

I would get an error, so does that mean there isnt one?

Ascii Code
Just looking for the ascii code for the back, forth, up and down arrows if there is any. I can't seem to locate them. any help would be appreciated.

Ascii Code
Do you know which Ascii codes represent the up, down, left and right arrows and also "Tab"? I need them for use with a grid.

&lt;&gt;&lt;

Ascii Code
Does Anyone have an Ascii converter(from normalkeyto Ascii) or a chart that I can view?

ASCII Code
Ok I know what function to use and have it show a letter as a number in a label, but how do you get it to show multiple letters as numbers.

Example: user types in the text box "Example"

the label would display : E=number X=number A=Number etc.


also another program im trying to code I need help with as well.

You click the command button and a input box comes up (I know how to code a input box) and the user types a # of words they will use to create a acronym, after that new input boxs come up for the amount they typed.

then those two words will creat a Acronym

example : Two words are Jack Lone, the label will have the first letter of both words displaying JL.

any help will be great thanks.

ASCII Code
can someone show me some code to create the ASCII thing, please

How To Get The Ascii Code For A Key.
how to get the ascii code for a key.

Ascii Code For Alt+tab
hi does anyone know the ascii for alt+tab? or at the least for alt?

Fix Ascii Code
if KeyAscii <> 13 Then
lblMessage.Visible = True
lblMessage.Caption = "Enter Expires Date:"
end if
if KeyAscii <> 13 Then
lblMessage.Visible = True
lblMessage.Caption = "Enter I.D. Number:"
end if
if KeyAscii <> 13 Then
lblMessage.Visible = True
lblMessage.Caption = "Enter Check Receipt:"
end if

so it will goto the next question

ASCII Code
Does anyone know what the ASCII codes for the function keys are? (i.e. F1, F2, F3 ...) and the codes for Ctrl, Alt, and Shift?

ASCII Code
Alrighty...

I know how to get the ASCII code of a character in VB, but does anyone know how to do it in Java?..

Copyright 2005-08 www.BigResource.com, All rights reserved