Click here to Skip to main content
15,921,841 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
dear all
please help

i have a code hexadecimal like this


and i get instruction like that "50 sets of 2-digit hexadecimal data, converted to ASCII"

from the convert, i want to show in database mysql image blob.

when i try i get the value is "

CdcG-$#$&& $-5>T^_]WMB:2% "

please help me

What I have tried:

Public Function HexToStr(ByVal Data As String) As String
        Dim com As String = ""
        For x = 0 To Data.Length - 1 Step 2
            com &= ChrW(CInt("&H" & Data.Substring(x, 2)))
        Return com
    End Function


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim st As String = TextBox1.Text
        Dim com As String
        Dim a As Integer = 0
        Dim b As Integer
        Dim c As String = ""
        ' while loop execution '

        b = TextBox1.Text.Count

        While a < b
            c = TextBox1.Text.Substring(0 + a, 2)
            com = HexToStr(c).ToString
            RichTextBox1.Text = RichTextBox1.Text & com
            a = a + 2
        End While
    End Sub
Updated 18-Dec-22 22:24pm
Richard Deeming 19-Dec-22 3:46am    
The hex data you've posted starts with a null character, and contains various ASCII control characters. It's clearly not intended to be a string to be shown to a human.

You need to talk to whoever gave you those incomplete instructions to find out precisely what the data represents, and how you're expected to decode and display it.

1 solution

The value you get is the value in your original string converted from hex characters to a string - the code you show works.

But ... it's way too short to be any realistic image, (even as a icon bitmap, it would only be about 3 pixels by 4) so I'd suspect that either it's been mangled or it's very incomplete.

I'd go back to where you got it from, and check carefully what exactly is expected - that isn't human readable data or an image!
Share this answer
Member 13297861 19-Dec-22 4:56am    
i get the hexadecimal from the instrument machine, and the instrument print that hexadecimal to a like histogram. I want to save the histogram picture to the database.

this link a histogram
OriginalGriff 19-Dec-22 5:05am    
I suspect that what you have is the histogram data points, not an image of the histogram. That would make sense for the size of the data sample.
Member 13297861 19-Dec-22 5:00am    
this original hexadecimal

and this link for how to action converting

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900