Give Code In VB For Binary Conv. Like 1010 Is Binary Of 10
Please give the code of Binary conversion in VB .
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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
Sending Binary Code Through USB
i am just wondering if there is any way to send binary code through the USB port. I am trying to communicate with my own circuit, it is only a very simple one and i need a specific set of 1's and 0's to make it work. I am only a beginner when it comes to visual basic so can you try and keep the solution simple.
Thanks heeps.
FInd Binary Code
I have to find binary code for a character like A ... is there a VB function (I am using VB.Net 2005) for it .. pls give me some idea about it .. pls do give any sample code if any
for eg : A - 65(ASCII Code) - 01000001 (Binary value of 65)
Binary Tree Code
In C++ you'd do something like:
Code:
struct Node
{
int data;
Node *right;
Node *left;
}
I think. Ported to VB, you could do this (without pointers, thank god):
VB Code:
Type TreeNode DataAtNode As Variant Dim RightN As Node Dim LeftN As NodeEnd Type
But I hate data structures, especially involving pointers, so does anyone else have an opinion?
Code For Binary Comms
Hi
Does anyone have an eVB routine to receive binary data.
I wrote a routine using the eVT3.0 Comm Control in binary mode, and it works OK except when chr(26) (EOF) is received, when extra chars are placed in the input buffer.
Here's part of the code:
Private Sub Comm1_OnComm()
Select Case Comm1.CommEvent
Case comEvReceive
'get number of bytes received
byteLen = Comm1.InBufferCount
'get data
ReceiveArray (Comm1.Input)
'update bytes received
rxed = rxed + byteLen
End Select
End Sub
Private Sub ReceiveArray(ByVal inArray As Variant)
Dim lCount As Long
'move data from input buffer
For lCount = 0 To UBound(inArray)
DataRx(rxed + lCount) = CByte(inArray(lCount))
Next lCount
End Sub
I have also tried the routine in the tutorial by David Knechtges at devbuzz.com, but that too suffers from the same problem.
Also, does anyone know of any third party controls, as the problem may be down to the Comm Control.
Thanks in advance.
Mark.
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
Need Help With Binary File Code
can anyone help me and tell me if there is anything wrong with this code
i cant seem to understand why it isn't working
Read and Str are strings,
Read holds the contents of file #1, which i want inserted after ByteSel bytes of the output file.
Read = Space(LOF(1))
Get #1, , Read
Str = Space(LOF(2) + LOF(1))
Get #2, , Str
Str = Left(Str, ByteSel) & Read & Mid(Str, ByteSel + 1)
Open "d: estfile.dtg" For Output As #5
Print #5, Str;
Close #5
Starting Code: Read Binary
hi, i am a 20 year old student who has to make an VB project for my final.
I have tought out a pretty nice project, but i can't get started. i have been browsing trough all major fora to find a solution, but the information is different or to complicated.
I have a reasonable beginner experience with vb, but i have some troubble starting.
i want to read the binary code from a file, alter it some and write it again.
can you give me the starting code?
read file: source.abc
write file: target.def
alteration: for example: if the last bit of a byte sequence is an "1" it should become a "0" (just for having an example)
i have some troubble reading (streaming, sequence, or howerever it works, and also the limit, obviously it isn't possible to load a file a few 100 mb in size at once) and how to handle the code.
from what i have seen on the fora, it should only be a few lines and if you could find this time, i would appreciate it. If so, can you explain every variable you use (clear name would be helpful to) andwhy you do that.
It isn't even 1% of my whole work, but if this would be possible to get me started, i can go on, since this problem took me stuck, even my teacher didn't knew it was even possible to read the binary code, so i shouldn't ask her help. i have particular problems reading the program in sequences of let's say 1 byte (8bits), or sth like that.
thx
greetings,
CD-R
Problem...hex Code E Binary File..
hi...I've got a problem...a small problem with this code..
Option Explicit
Dim b As String
Dim a As String
Dim c As Long
Dim d As Long
Dim e As Long
Dim f As String
Dim g As String
Dim h As String
Private Sub Command1_Click()
'scrittura primo indirizzo
b = "/Exe/Java/" & Chr$(0)
Seek #1, c
Put #1, , b
Label1.Caption = "deve apparire /Exe/Java/"
'scrittura secondo indirizzo
Seek #1, d
Put #1, , b
Label2.Caption = " deve apparire /Exe/Java/"
'scrittura terzo indirizzo
h = "/Exe/Java" & Chr$(0)
Seek #1, e
Put #1, , h
Label3.Caption = "deve apparire /Exe/Java"
End Sub
Private Sub Command2_Click()
' rilettura primo indirizzo
Seek #1, c
a = Space$(11)
Get #1, , a
Text1.Text = a
' rilettura secondo indirizzo
Seek #1, d
f = Space$(11)
Get #1, , f
Text3.Text = f
' rilettura terzo indirizzo
Seek #1, e
g = Space$(10)
Get #1, , g
Text5.Text = g
End Sub
Private Sub Command3_Click()
On Error GoTo errore
c = Val("&H" & Text2.Text & "")
d = Val("&H" & Text4.Text & "")
e = Val("&H" & Text6.Text & "")
'lettura primo indirizzo
Seek #1, c
a = Space$(12)
Get #1, , a
Text1.Text = a
' lettura secondo indirizzo
Seek #1, d
f = Space$(11)
Get #1, , f
Text3.Text = f
'lettura terzo indirizzo
Seek #1, e
g = Space$(11)
Get #1, , g
Text5.Text = g
Exit Sub
errore:
MsgBox ("inserisci gli indirizzi in esadecimale")
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub File1_Click()
Open (File1.Path & "" & File1.FileName) For Binary Access Read Write As #1
Command4.BackColor = vbGreen
Command4.Caption = "file caricato"
End Sub
in this code i load a binary file...then I insert in a text box an hex address....this address is converted in a decimal code...so I substitude the word "/Media/Etc/ with "/Exe/Java/".
NOW i've got a problem when i write in text box the hex address the program can't read the exact address but a previous number (I insert 00A5F361 and it read 00A5F360) and so also substitude is not good...WHY???thanks!!!
Access Binary Code / Golf Tip
I'm using Access in office premium. How can I protect my programs from being accessed / changed by other programmers ? do i need the programming version of Access. Where can I get that FOC ?
Golf Tip : Stop slicing off the tee.
1. tee the ball higher
2. move it forward a couple of inches in your stance
3. turn properly on the back swing
4. & this is the important one. Let the club do the work / lead !!!
try it if it doesn't work ill give you your money back
Wav File Binary Code Display
hii, i am seek for help to display the amplitude of the wave for wav file in binary code(PCM)...Does any one of u able to provide any code or command to me ....i really appreciate your help..thanx
Sending Binary Code To Hardware Thru Serial
I have a piece of circuit that takes in 4 bit binary input ie. 1111, 0101 etc. Im trying to send it this binary code thru serial. Can someone tell me if this is possible?
if i want to send a code of 1111, do i just have to output chr(14) ? Thanks so much for your help
Embedding Binary (machine) Code Block Into VB
Hi,
I have an old GW-Basic program that I'd like to resurrect part of it for VB. It used "POKE" to place a small 128 byte binary code block into Basic's address segment.
I'm wondering if there is any way to do something similar in VB. I'm thinking of perhaps a Byte array.
Has anyone ever persued doing this?
Below is the GW-Basic code that did this.
Thanks,
Al.
Code:
2640 ' Put API interface assembler code into memory.
2642 '
2644 CF$ = "WSFSBPAI.BIN" 'Input file name.
2645 AO% = 0'Memory address offset.
2646 OPEN CF$ AS #2 LEN=128'Open input file.
2648 FIELD #2, 128 AS B$'Define input buffer.
2649 CFL% = LOF(2)'Get length of file.
2650 WR% = (CFL%128)+1 'Calculate number of whole records.
2651 ' Read API interface code and poke into memory.
2652 FOR L1% = 1 TO WR%: GET #2
2653 FOR L2% = 1 TO 128: POKE AO%,ASC(MID$(B$,L2%,1)): AO% = AO%+1: NEXT L2%
2654 NEXT L1%
2658 APII% = 0'Save address of API interface CALL handling code.
2660 DEF USR0 = 3'Save address of API interface USR handling code.
2662 RC%=0: FUNCCODE%=0: FUNCNO%=0: APIREL$=" ": APIVER$=" "
2664 CALL APII%(RC%,FUNCCODE%,APIREL$,APIVER$,FUNCNO%) 'Retrieve API version information.
2666 IF FUNCCODE%<>&H0012 OR RC%<>0 THEN 2686 'API version not retrieved?
2668 PRINT "WSF API version ";APIVER$;", release ";APIREL$;" is running."
2670 SYSAV=2: ROWA=3 :'Define equates for WSF data items.
2682 RETURN
How To Make A Binary Code For All Access Record
Hi...all,
I'm writing a Database aplication by implementing a genetics algorithm to create a fixed scedule for lecturing.
I'd made a database with access, and to proccess (transaction) the database, I used VB 6.
The database had fullfilled, and the next step is to generate binary code for all records, and then will made a cross over.
Please help me, how to take each record from database and generate it's binary code for each record.
TQ
Conversion Binary To Binary And Conversion Of Hexadecimal To Decimal In Calculator
Hi Folks
i was develop one scientific calculator
1) binary to binary conversion= for example we can add one binary value (1110) + another binary value(0101) = i want this output(100 1 1)but it comes 1211 this is my question how can i rectify ?
2) convert from hexadecimal to decimal conversions (ex)in decimal 12 to hexa is c . it wirks good ,but my question is how to convert hexadecimal to deimal (12) ?
Tks in Advance
----------------------------------------------------------------------
HARD WORK NEVER END FAILS"
Binary Clock Program - All Of The Code For Timer Being Executed
I am writing an app that will display a binary clock. However when I try to use this code all of the "on" images (Image5 through Image8) are displayed. I want the on images to displayed only when the counter reaches the specific numbers.
Here is my code:
Code:
Dim secCounter As Integer
Dim minOnesCounter As Integer
Dim minTensCounter As Integer
Dim hourOnesCounter As Integer
Dim hourTensCounter As Integer
Private Sub Command1_Click()
Timer1.Enabled = True
'secCounter = 1
End Sub
Private Sub Timer1_Timer()
secCounter = secCounter + 1
Text1.Text = secCounter
If secCounter = 10 Then
secCounter = 0
End If
If secCounter = 1 Or 3 Or 5 Or 7 Or 9 Then
Image1.Visible = False
Image5.Visible = True
End If
If secCounter = 2 Or 3 Or 6 Or 7 Then
Image2.Visible = False
Image6.Visible = True
End If
If secCounter = 4 Or 5 Or 6 Or 7 Then
Image3.Visible = False
Image7.Visible = True
End If
If secCounter = 8 Or 9 Then
Image4.Visible = False
Image8.Visible = True
End If
End Sub
Binary Search Data1.Recordset ... 1 Line Of Code Needed
HELP!! Ive tried to do a binary search on the following Access Database through Data1.recordset.
I think that only one line of code needs to be changed: how to specify a Long Variable type to equal the first record in the database.
Its highlighted in red below, I think this is all that needs to be changed, but am not sure.....
Option Explicit
Dim db As Database
Dim rs As Recordset
Private Sub Command1_Click()
Dim hit As Boolean, fTop As Long
Dim fBott As Long, fTmp As Long
If txtSearch.Text = "" Then
MsgBox "Nothing to do."
txtSearch.SetFocus
Exit Sub
End If
hit = False
fTop = Data1.Recordset.RecordCount - 1
fBott = 0
fTmp = (fTop + fBott) / 2
Do While (Not hit) And (fTop >= fBott)
Data1.Recordset. = fTmp
'WHAT DO I PUT IN HERE TO MAKE fTmp = FIRST RECORD ??
If Data1.Recordset("Staff Number") = txtSearch.Text Then
hit = True
ElseIf Text1.Text < Data1.Recordset("Staff Number") Then
fTop = fTmp - 1
Else
fBott = fTmp + 1
End If
fTmp = (fTop + fBott) / 2
If Not hit Then
MsgBox "No match"
Else
txtSurname.Text = Data1.Recordset("Surname")
End If
Loop
txtSearch.SetFocus
End Sub
Binary And Binary Access
hey,
First anybody got a good Tutorials talking about Binary and Binary Access...
Now whats the difference between:
Code:
Open "C:FILE.exe" For Binary Access Write As #1
and
Code:
Open "C:FILE.EXE" For Binary As #1
and how does these thing work and what does they do?
Merging Binary Files To One Binary Files
Hi,
in a prog of mine i have to merge several binary files to one large. In a other prog the large file will be split again to these binary files.
I've made it this way:
Put iFileNumber, , iNoOfRecords
for i = 1 to iNoOfRecords
Open App.Path & "
dftmp" & i & ".tmp" for binary Access Read Write as rdfFileHandle
LengthOfFile = LOF(rdfFileHandle)
record = Space(LengthOfFile)
'Speicher Allgemeine Reportinfos in rdf-Datei
get rdfFileHandle, , record
Put iFileNumber, , record
Close rdfFileHandle
next i
In my other prog i have following to read my records out again:
for i = 1 to iNoOfRecords
'***************************************************************************************************************************
'* Allgemeine Daten, die jeder Report besitzt
'***************************************************************************************************************************
get aFileNumber, , bHasParameter 'Hat aktueller Bericht Parameter
TemporaryFileNumber = FreeFile
Open App.Path & "RDFTMP" & iCurrentRecord & ".tmp" for binary Access Read Write as TemporaryFileNumber
'Put TemporaryFileNumber, , stringlength
'Put TemporaryFileNumber, , RDFTag
Put TemporaryFileNumber, , bHasParameter
'Seitenname
get aFileNumber, , stringlength
PageName = Space(stringlength)
get aFileNumber, , PageName
Put TemporaryFileNumber, , stringlength
Put TemporaryFileNumber, , PageName
'Berichtname
get aFileNumber, , stringlength
ReportName = Space(stringlength)
get aFileNumber, , ReportName
Put TemporaryFileNumber, , stringlength
Put TemporaryFileNumber, , ReportName
'InfoDatei
get aFileNumber, , stringlength
InfoFile = Space(stringlength)
get aFileNumber, , InfoFile
Put TemporaryFileNumber, , stringlength
Put TemporaryFileNumber, , InfoFile
'ReportDatei
get aFileNumber, , stringlength
ReportFile = Space(stringlength)
get aFileNumber, , ReportFile
Put TemporaryFileNumber, , stringlength
Put TemporaryFileNumber, , ReportFile
'Zusatzinformationen
get aFileNumber, , stringlength
AdditionInfo = Space(stringlength)
get aFileNumber, , AdditionInfo
Put TemporaryFileNumber, , stringlength
Put TemporaryFileNumber, , AdditionInfo
Close TemporaryFileNumber
next
The problem is that only the first record will be displayed correct. Any further record gets lost.
Does anyone knows a good solution to this???
Thanks
Akademos
10 + 10 = 1010?
Hi,
Ok, so I'm simply trying to sum the values in two textboxes, but I can't for the life of me figure out how to do it. The program reads the values as strings and simply adds them on the end of each other (10 + 10 = 1010) when I want the values themselves to be added (10 + 10 = 20).
Here's my code as of now:
Dim x As Double
x = textbox1 + textbox2
Output.Caption = x
I've tried adding CDbl, CInt, CSng and CVar in front of textbox1 and textbox2, but it doesn't work.
It's probably a really stupid question, but can anyone help?
Thanks,
Jon
Binary
Why when i check if a registry value exists by name i cant get a Reg_Binary to confirm that it exists.
Like i do
If regDoes_Val_exist(Rootkey, Subkeys, ValueName) <= My own function
It returns all values except if they are binary. :-/
I have all the data types and Root Keys classified. ?? Thanx
Binary Again
hi, how do i set the start point of where to get the data from in a binary file. so....
open filename for binary access read as #1
dim temp as string
temp = space$(500)
get #1,,temp
this will get 500 bytes from the file. now how do i get the NEXT 500 bytes. how do i tell it where to start from?
Binary 1&&0's
hey,
i need a file displayed in a textbox in 1's and 0's.. how could i do that?
i only have to know how i could get the input from the file..
very much thnx in advance.
Ocx As Binary
can someone post a code on how to open an ocx file as binary, so i can put that code in my exe, then have it, when the exe is opened, go back to an ocx and extract on whoever opens its computer.
Binary Help Please?
Whats the code to open a File any file into binary and dumping the 1's and 0's into a text file?
Private Sub Form_Load()
Open ("C:File.jpg") For Binary As #FF
lngChunkSize = LOF(FF)
strdata = String$(lngChunkSize, 0)
Get #FF, , strdata
Open ("C:File.txt") For Append As #FG
Print #FG, strdata
Close #FF
Close #FG
End Sub
Something like that?
Binary
Okay could anyone clue me in about how to save data into binary files?
and how to load them?
thanx in advance
Binary
Hi
I am new to visual basic.. i am wondering how do i display my data in binary??? or hex
cheers
Binary Help
i want to create a program that converts ASCII to Binary and Binary to ASCII but i don't know where to start
Binary
how to do convert a number into binary...
Binary In VB
Except open "filename" for binary as #filenumber, How can I write a binary file in VB?
thx!
Binary
just wondered what the code of other programs is in. is it stored as binaru or as an other. if so how could i see the binary?
stead ;)
Hex To Binary
is there a simple procedure for converting a hex figure into a binary code. i need to then view the last 2 nibbles. are binary numbers reversed when viewing them?
ie hex 53
binary 0101 0101 0101 0111 (this is just an example)
would the last 2 nibbles be at the front (01) or the end (11), or do they need reversing also ie at the front (10) or the end (11)
thanks
Hex To Binary
if this converts hex to Decimal
vb Code:
B2 = ("&H" & B1)
Is there a simple way to convert Hex to Binary?
Dec To Binary?
it really takes a page of code to convert hex to binary? and dec to hex etc,,,? i am working with textboxes
text1
text2
text3
binary decimal and hex, been searching the net, i think very few people know this conversion ehh, sheesh
This does work. butt needs more work
Private Sub Command1_Click()
dec = Text1
dec = hex(dec)
Text2 = dec
End Sub
Binary
Can any of you convert this to readable text?
VB Code:
2228328527259562135828535257140128010250030-2339200128200256050010000000000000000000001156318219-23441-23392
and show me how please.. :/
Binary --> Hex.....
Is there anybody knows how to convert Binary file (e.g. .gif, .bmp) into Hex code?
Please help
Binary
anybody know any good sites that can give me a good introduction to using binary? Thanks.
Binary
What i am doing is making a Binary clock.
The form will have red (or black) circles on it aligned in it (look at the attached picture)
what i want to know is is there an eassyer way to change the collors of the circles without doing somthing like this:
VB Code:
If A = 1 ThenCircle1.Backround = &H0000008Circle1.Backround = &H0000008Circle1.Backround = &H0000008Circle1.Backround = &H0000008Circle1.Backround = &H0000008Circle1.Backround = &H0000008Circle1.Backround = &H00000FFElseIf A = 2 ThenCircle1.Backround = &H0000008Circle1.Backround = &H0000008Circle1.Backround = &H0000008Circle1.Backround = &H0000008Circle1.Backround = &H0000008Circle1.Backround = &H0000008Circle1.Backround = &H00000FFCircle1.Backround = &H0000008'ecx...
Maby somthing like a for statement.
Thank You
Nathan
(I am doing this project to practice and examples for my real projects [Just For Fun])
Binary Value
ok..i searched the forums and api guide, but i got nothing..
is there a way (such as Hex$()) to obtain the binary value of a character? something like Bin$("A") or something (which there isnt..i checked definitions also, but its just IE)?
Binary
I have a field in a database that is stored as binary.
I retrieve it into a string variable. How can I read it?
Hex To Binary
I apologize in advance as I am new to VB but I can't punch the registry on a remote pc using REG_BINARY. I'm trying to get the following key into the registry
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USERSoftwareMicrosoftConferencingAudio Control]
"Calibrated Volume"=hex:ff,ff,00,00
My code looks like this
Dim lRet As Long
'Connect to the remote registry
lRet = RegConnectRegistry("\" & PCInfo.HostText, _
HKEY_CURRENT_USER, _
hRemoteReg)
If (lRet = ERROR_SUCCESS) Then
Dim lRetVal As Long
Dim hKey As Long
Dim sValue As String
Dim hregkey As Long
Dim SubKey As String
Dim stringbuffer As String
SubKey = "SoftwareMicrosoftConferencingAudio Control
lRetVal = RegOpenKeyEx(hRemoteReg, SubKey, 0, _
KEY_WRITE, hregkey)
If lRetVal <> 0 Then
MsgBox "Can't open the subkey"
Exit Sub
End If
lRetVal = RegSetValueEx(hregkey, "Calibrated Volume", 0, REG_BINARY, _
ByVal "ffff0000", Len("ffff0000"))
If lRetVal <> 0 Then
MsgBox "Registry successfully Updated"
RegCloseKey hregkey
Else
MsgBox "Can't update Registry"
Unload Me
Exit Sub
End If
It punches the registry as 66 66 66 66 30 30 30 30
I'm sure this is a pretty simple thing that I am overlooking but I can't find it.
Any help you can lend would be greatly appreciated.
Thanks in advance.
Vb3 Binary
Hi. I have some old vb3 forms and they are in binary. I don't have vb3 anymore and can't open them in vb6. Does anybody know how to convert these or have a copy of vb3 they could send me. Thanks.
|