dcsimg
Results 1 to 4 of 4

Thread: Error BC30311 "Value of type 'Byte' cannot be converted to 'Bitmap'."

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2018
    Posts
    49

    Question Error BC30311 "Value of type 'Byte' cannot be converted to 'Bitmap'."

    I'm getting an error in my VB.Net application, which says:

    HTML Code:
     Error BC30311 "Value of type 'Byte' cannot be converted to 'Bitmap'."

    Now, the strange thing is, is that I've created another Form to test out the code I'm using, and it works fine in that other Form, but not the Form I'm using now. I've tried copying all of the settings from the other Form to the Form I'm using now, but that's still not working. Here is my code:

    HTML Code:
    Private Sub Mainframe_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
            Dim procs() As System.Diagnostics.Process = System.Diagnostics.Process.GetProcesses
            Dim f As String
    
            For Each proc As System.Diagnostics.Process In procs
                f = GetProcessFileName(proc)
                If f.Length > 0 Then
                    ListBox1.Items.Add(f)
                    ListBox1.Items.Add("MD5: " & GetMD5String(f))
                    ListBox1.Items.Add(String.Empty)
                End If
    
            Next
    
        End Sub
    
        Private Function GetProcessFileName(proc As System.Diagnostics.Process) As String
            Dim strRet As String = String.Empty
    
            Try
                strRet = proc.MainModule.FileName
            Catch ex As Exception
                ' This catch used to ignore "Access is denied" exception.
            End Try
            Return strRet
        End Function
    
        Private Function GetMD5String(ByVal strFilename As String) As String
            Dim cMD5 = System.Security.Cryptography.MD5.Create
            Dim bytHash As Byte()
            Dim sb As New System.Text.StringBuilder
            Dim scanbox As New TextBox
            scanbox.Text = My.Computer.FileSystem.ReadAllText("viruslist.txt").ToString
    
            Using cStream As New IO.FileStream(strFilename, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
    
                bytHash = cMD5.ComputeHash(cStream)
            End Using
    
            For Each B In bytHash
                sb.Append(B.ToString("X2"))
            Next
    
            If scanbox.Text.Contains(sb.ToString) Then
                Detect.Show()
            End If
    
            Return sb.ToString
    
    
    
        End Function

    Where it says
    HTML Code:
    For Each B In bytHash
    under
    HTML Code:
    bytHash
    is where I'm getting my error. Can someone please tell me what I'm doing wrong?

    Thanks.

  2. #2
    Frenzied Member
    Join Date
    May 2014
    Location
    Central Europe
    Posts
    1,272

    Re: Error BC30311 "Value of type 'Byte' cannot be converted to 'Bitmap'."

    place the Cursor (the caret to be more exact) directly before or after that "B" variable, then hit F12. It will take you to the declaration of the var which obviously is somewhere else in your Project and there B is most likely declared as Bitmap.

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2018
    Posts
    49

    Re: Error BC30311 "Value of type 'Byte' cannot be converted to 'Bitmap'."

    Ok.


    Yes, it is a bitmap. What should I change it too?

    Thanks!

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2018
    Posts
    49

    Re: Error BC30311 "Value of type 'Byte' cannot be converted to 'Bitmap'."

    Nevermind! 'B' was a FlatUI component. Changed it and it worked!


    Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width