473,651 Members | 2,566 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to convert Binary data to original text?

27 New Member
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 7205
zerok666
25 New Member
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
4471
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 System.Text.UnicodeEncoding enc = new System.Text.UnicodeEncoding(); now i am using enc.GetString(value) and the value retured is one byte less if the size of the byte array is Odd. In case of files having even number of bytes, the convertion is happening correctly and...
4
3684
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 following code that compiles OK. It runs and shows the requested output. However, after execution, it pops one of those windows to send error reports online to the porgram creator. I have managed to find where the error is but can't see what's wrong....
6
28075
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
19210
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 00000000000000001111111111111111 11111111111111111111111111111111 00000000000000000000000000000000 11111111111111110000000000000000
29
5073
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 something like ascii text editor. I'd also like to be able to read the binary formed data back into string format so that it shows the original value. Is there any way to do this in Python? Thanks!
6
1586
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
5255
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 Convert.FromBase64String seem like the closest thing I can find to what I'm looking for baked into the base class library. Can anyone suggest a better way to do this? TIA - Bob
22
11755
by: xiao | last post by:
Can I fullfill this task? Using fred and fwrite?
0
10751
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 inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not a new concept, there is a concept called Steganography which enables to conceal your secret...
0
8352
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8697
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8465
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8579
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5612
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1587
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.