473,387 Members | 1,882 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,387 software developers and data experts.

How to convert Binary data to original text?

27
I am sending binary data from ASP to dll in VB.I am able to receive the data,but it is in binary format.can anybody plz tell me how to convert binary data to original text in VB.(I am saving data in variable,n receiving on Dll.)
Apr 22 '08 #1
1 7180
if i understand your question correctly, you want to take pure binary code and change it to ascii. if that is correct, then this might help, but you will need to code it for your program (it gets explained at the end):


Public Sub unconvert(kk As String)
Dim tl As Integer
tl = (Len(kk) / 8)
Dim I As Integer

For I = 1 To tl
If I = "1" Then
buff = Mid(kk, I, 8)
Else
buff = Mid(kk, ((I - 1) * 8) + 1, 8)
End If

hh = buff
If Mid(hh, 1, 1) = "0" Then If Len(hh) > 1 Then hh = Mid(hh, 2, (Len(hh) - 1))
Select Case hh

Case 0: buff = Chr(0)
Case 1: buff = Chr(1)
Case 10: buff = Chr(2)
Case 11: buff = Chr(3)
Case 100: buff = Chr(4)
Case 101: buff = Chr(5)
Case 110: buff = Chr(6)
Case 111: buff = Chr(7)
Case 1000: buff = Chr(8)
Case 1001: buff = Chr(9)
Case 1010: buff = Chr(10)
Case 1011: buff = Chr(11)
Case 1100: buff = Chr(12)
Case 1101: buff = Chr(13)
Case 1110: buff = Chr(14)
Case 1111: buff = Chr(15)
Case 10000: buff = Chr(16)
Case 10001: buff = Chr(17)
Case 10010: buff = Chr(18)
Case 10011: buff = Chr(19)
Case 10100: buff = Chr(20)
Case 10101: buff = Chr(21)
Case 10110: buff = Chr(22)
Case 10111: buff = Chr(23)
Case 11000: buff = Chr(24)
Case 11001: buff = Chr(25)
Case 11010: buff = Chr(26)
Case 11011: buff = Chr(27)
Case 11100: buff = Chr(28)
Case 11101: buff = Chr(29)
Case 11110: buff = Chr(30)
Case 11111: buff = Chr(31)
Case 100000: buff = Chr(32)
Case 100001: buff = Chr(33)
Case 100010: buff = Chr(34)
Case 100011: buff = Chr(35)
Case 100100: buff = Chr(36)
Case 100101: buff = Chr(37)
Case 100110: buff = Chr(38)
Case 100111: buff = Chr(39)
Case 101000: buff = Chr(40)
Case 101001: buff = Chr(41)
Case 101010: buff = Chr(42)
Case 101011: buff = Chr(43)
Case 101100: buff = Chr(44)
Case 101101: buff = Chr(45)
Case 101110: buff = Chr(46)
Case 101111: buff = Chr(47)
Case 110000: buff = Chr(48)
Case 110001: buff = Chr(49)
Case 110010: buff = Chr(50)
Case 110011: buff = Chr(51)
Case 110100: buff = Chr(52)
Case 110101: buff = Chr(53)
Case 110110: buff = Chr(54)
Case 110111: buff = Chr(55)
Case 111000: buff = Chr(56)
Case 111001: buff = Chr(57)
Case 111010: buff = Chr(58)
Case 111011: buff = Chr(59)
Case 111100: buff = Chr(60)
Case 111101: buff = Chr(61)
Case 111110: buff = Chr(62)
Case 111111: buff = Chr(63)
Case 1000000: buff = Chr(64)
Case 1000001: buff = Chr(65)
Case 1000010: buff = Chr(66)
Case 1000011: buff = Chr(67)
Case 1000100: buff = Chr(68)
Case 1000101: buff = Chr(69)
Case 1000110: buff = Chr(70)
Case 1000111: buff = Chr(71)
Case 1001000: buff = Chr(72)
Case 1001001: buff = Chr(73)
Case 1001010: buff = Chr(74)
Case 1001011: buff = Chr(75)
Case 1001100: buff = Chr(76)
Case 1001101: buff = Chr(77)
Case 1001110: buff = Chr(78)
Case 1001111: buff = Chr(79)
Case 1010000: buff = Chr(80)
Case 1010001: buff = Chr(81)
Case 1010010: buff = Chr(82)
Case 1010011: buff = Chr(83)
Case 1010100: buff = Chr(84)
Case 1010101: buff = Chr(85)
Case 1010110: buff = Chr(86)
Case 1010111: buff = Chr(87)
Case 1011000: buff = Chr(88)
Case 1011001: buff = Chr(89)
Case 1011010: buff = Chr(90)
Case 1011011: buff = Chr(91)
Case 1011100: buff = Chr(92)
Case 1011101: buff = Chr(93)
Case 1011110: buff = Chr(94)
Case 1011111: buff = Chr(95)
Case 1100000: buff = Chr(96)
Case 1100001: buff = Chr(97)
Case 1100010: buff = Chr(98)
Case 1100011: buff = Chr(99)
Case 1100100: buff = Chr(100)
Case 1100101: buff = Chr(101)
Case 1100110: buff = Chr(102)
Case 1100111: buff = Chr(103)
Case 1101000: buff = Chr(104)
Case 1101001: buff = Chr(105)
Case 1101010: buff = Chr(106)
Case 1101011: buff = Chr(107)
Case 1101100: buff = Chr(108)
Case 1101101: buff = Chr(109)
Case 1101110: buff = Chr(110)
Case 1101111: buff = Chr(111)
Case 1110000: buff = Chr(112)
Case 1110001: buff = Chr(113)
Case 1110010: buff = Chr(114)
Case 1110011: buff = Chr(115)
Case 1110100: buff = Chr(116)
Case 1110101: buff = Chr(117)
Case 1110110: buff = Chr(118)
Case 1110111: buff = Chr(119)
Case 1111000: buff = Chr(120)
Case 1111001: buff = Chr(121)
Case 1111010: buff = Chr(122)
Case 1111011: buff = Chr(123)
Case 1111100: buff = Chr(124)
Case 1111101: buff = Chr(125)
Case 1111110: buff = Chr(126)
Case 1111111: buff = Chr(127)
Case 10000000: buff = Chr(128)
Case 10000001: buff = Chr(129)
Case 10000010: buff = Chr(130)
Case 10000011: buff = Chr(131)
Case 10000100: buff = Chr(132)
Case 10000101: buff = Chr(133)
Case 10000110: buff = Chr(134)
Case 10000111: buff = Chr(135)
Case 10001000: buff = Chr(136)
Case 10001001: buff = Chr(137)
Case 10001010: buff = Chr(138)
Case 10001011: buff = Chr(139)
Case 10001100: buff = Chr(140)
Case 10001101: buff = Chr(141)
Case 10001110: buff = Chr(142)
Case 10001111: buff = Chr(143)
Case 10010000: buff = Chr(144)
Case 10010001: buff = Chr(145)
Case 10010010: buff = Chr(146)
Case 10010011: buff = Chr(147)
Case 10010100: buff = Chr(148)
Case 10010101: buff = Chr(149)
Case 10010110: buff = Chr(150)
Case 10010111: buff = Chr(151)
Case 10011000: buff = Chr(152)
Case 10011001: buff = Chr(153)
Case 10011010: buff = Chr(154)
Case 10011011: buff = Chr(155)
Case 10011100: buff = Chr(156)
Case 10011101: buff = Chr(157)
Case 10011110: buff = Chr(158)
Case 10011111: buff = Chr(159)
Case 10100000: buff = Chr(160)
Case 10100001: buff = Chr(161)
Case 10100010: buff = Chr(162)
Case 10100011: buff = Chr(163)
Case 10100100: buff = Chr(164)
Case 10100101: buff = Chr(165)
Case 10100110: buff = Chr(166)
Case 10100111: buff = Chr(167)
Case 10101000: buff = Chr(168)
Case 10101001: buff = Chr(169)
Case 10101010: buff = Chr(170)
Case 10101011: buff = Chr(171)
Case 10101100: buff = Chr(172)
Case 10101101: buff = Chr(173)
Case 10101110: buff = Chr(174)
Case 10101111: buff = Chr(175)
Case 10110000: buff = Chr(176)
Case 10110001: buff = Chr(177)
Case 10110010: buff = Chr(178)
Case 10110011: buff = Chr(179)
Case 10110100: buff = Chr(180)
Case 10110101: buff = Chr(181)
Case 10110110: buff = Chr(182)
Case 10110111: buff = Chr(183)
Case 10111000: buff = Chr(184)
Case 10111001: buff = Chr(185)
Case 10111010: buff = Chr(186)
Case 10111011: buff = Chr(187)
Case 10111100: buff = Chr(188)
Case 10111101: buff = Chr(189)
Case 10111110: buff = Chr(190)
Case 10111111: buff = Chr(191)
Case 11000000: buff = Chr(192)
Case 11000001: buff = Chr(193)
Case 11000010: buff = Chr(194)
Case 11000011: buff = Chr(195)
Case 11000100: buff = Chr(196)
Case 11000101: buff = Chr(197)
Case 11000110: buff = Chr(198)
Case 11000111: buff = Chr(199)
Case 11001000: buff = Chr(200)
Case 11001001: buff = Chr(201)
Case 11001010: buff = Chr(202)
Case 11001011: buff = Chr(203)
Case 11001100: buff = Chr(204)
Case 11001101: buff = Chr(205)
Case 11001110: buff = Chr(206)
Case 11001111: buff = Chr(207)
Case 11010000: buff = Chr(208)
Case 11010001: buff = Chr(209)
Case 11010010: buff = Chr(210)
Case 11010011: buff = Chr(211)
Case 11010100: buff = Chr(212)
Case 11010101: buff = Chr(213)
Case 11010110: buff = Chr(214)
Case 11010111: buff = Chr(215)
Case 11011000: buff = Chr(216)
Case 11011001: buff = Chr(217)
Case 11011010: buff = Chr(218)
Case 11011011: buff = Chr(219)
Case 11011100: buff = Chr(220)
Case 11011101: buff = Chr(221)
Case 11011110: buff = Chr(222)
Case 11011111: buff = Chr(223)
Case 11100000: buff = Chr(224)
Case 11100001: buff = Chr(225)
Case 11100010: buff = Chr(226)
Case 11100011: buff = Chr(227)
Case 11100100: buff = Chr(228)
Case 11100101: buff = Chr(229)
Case 11100110: buff = Chr(230)
Case 11100111: buff = Chr(231)
Case 11101000: buff = Chr(232)
Case 11101001: buff = Chr(233)
Case 11101010: buff = Chr(234)
Case 11101011: buff = Chr(235)
Case 11101100: buff = Chr(236)
Case 11101101: buff = Chr(237)
Case 11101110: buff = Chr(238)
Case 11101111: buff = Chr(239)
Case 11110000: buff = Chr(240)
Case 11110001: buff = Chr(241)
Case 11110010: buff = Chr(242)
Case 11110011: buff = Chr(243)
Case 11110100: buff = Chr(244)
Case 11110101: buff = Chr(245)
Case 11110110: buff = Chr(246)
Case 11110111: buff = Chr(247)
Case 11111000: buff = Chr(248)
Case 11111001: buff = Chr(249)
Case 11111010: buff = Chr(250)
Case 11111011: buff = Chr(251)
Case 11111100: buff = Chr(252)
Case 11111101: buff = Chr(253)
Case 11111110: buff = Chr(254)
Case 11111111: buff = Chr(255)
End Select
outbuff = outbuff & buff
Next I

End Sub

tl stands for total length, it verifys when you are done
i is the location of where it is decodeing
hh is a temporary string
buff is used as another temporary string
the colon is used to keep the cases on a single line instead of two
outbuff is the final result, it has to be declared in the general declarations

i hope this helps ya out
Apr 23 '08 #2

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

Similar topics

1
by: Swarup | last post by:
I am reading a file (txt, xml, gif, ico, bmp etc) byte by byte and filling it into a byte arry. Now i have to convert it into a string to store it in the database. I use...
4
by: knapak | last post by:
Hello I'm a self instructed amateur attempting to read a huge file from disk... so bear with me please... I just learned that reading a file in binary is faster than text. So I wrote the...
6
by: as400tips | last post by:
I have a Binary Data file (Packed Decimal and ASCII mixed) and would like to convert into ASCII (readable) file. How to do it in C#? Thanks.
7
by: elliotng.ee | last post by:
I have a text file that contains a header 32-bit binary. For example, the text file could be: %%This is the input text %%test.txt Date: Tue Dec 26 14:03:35 2006...
29
by: Harlin Seritt | last post by:
Hi... I would like to take a string like 'supercalifragilisticexpialidocius' and write it to a file in binary forms -- this way a user cannot read the string in case they were try to open in...
6
by: G | last post by:
Hello, I would like to convert string "I am a fish" into a hex string if easy? Fairly new to .NET and have looked on google etc without much luck. Any help appreciated, Gary.
6
by: Bob Altman | last post by:
Hi all, I'm looking for the fastest way to convert an array of bytes to String. I also need to convert a String back to its original Byte() representation. Convert.ToBase64String and...
22
by: xiao | last post by:
Can I fullfill this task? Using fred and fwrite?
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.