Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42202

VS 2010 Help: value of type 'system.drawing.image' cannot be converted to 'string'

$
0
0
I am using the following function to convert image to hash: Public Function MD5Hash(ByVal sFile As String) As String

When I use this:

Code:


 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim picture As String = ("C:\Users\Public\Pictures\Sample Pictures\Desert.jpg")
        Dim hsh As String = MD5FileHash(picture)
        TextBox1.Text = hsh

    End Sub

^^ it works just fine.

But when I try something like this:

Code:


 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
   
        Dim openfile As New OpenFileDialog
        If openfile.ShowDialog = Windows.Forms.DialogResult.OK Then
        PictureBox1.Image = Image.FromFile(openfile.FileName)
        End If
        Dim hsh As String = MD5FileHash(picturebox1.image)
        TextBox1.Text = hsh

    End Sub

^^ IT does not work... because it cannot be converted to string?

I have also tried picturebox1.image.tostring. Also does not work.

How do I fix this?

:confused::confused:

Viewing all articles
Browse latest Browse all 42202

Trending Articles