I used this code to store convert pictures to "binary" inoreder to save in database but it stores only one picture from two pictureboxes.


let someone show me how, you can convert pictuers in two seperate 'picturebox ("picturebox1 and Picturebox2")' using the function in the code snippet on something similar.
and also using the "if" condition to validate checks

Comments
doing a great job for budding programmers
Public Function GetByteArrayFromImage2() As Byte()
        Dim piccollect As New PictureBox
        

        Dim ms As New System.IO.MemoryStream
        With PictureBox2
            .Image.Save(ms, PictureBox2.Image.RawFormat)


        End With


        Dim outBytes(CInt(ms.Length - 1)) As Byte
        ms.Seek(0, System.IO.SeekOrigin.Begin)
        ms.Read(outBytes, 0, CInt(ms.Length))
        Return outBytes
        GetByteArrayFromImage2 = ms.GetBuffer
        ms.Close()
    End Function

http://www.daniweb.com/forum58.html


1. You declare piccollect, assign it memory and then never use it.
2. You ask how to handle multiple picture boxes. Don't hardcode the picture box!!!!

Public Function GetByteArrayFromImage2(ByRef pb as PictureBox ) As Byte() Dim ms As New System.IO.MemoryStream With pb .Image.Save(ms, pb.Image.RawFormat) End With [\code] ...

[code=vb] Dim a(0) as Byte Dim b(0) as Byte a = GetByteArrayFromImage2(picturebox1) b = GetByteArrayFromImage2(Picturebox2) [\code] 3. "Return outBytes" terminates your logic, the last two statements are never executed. The only way they would execute is if the above statement was in an If statement and the false path is followed.[code=vb]
Public Function GetByteArrayFromImage2(ByRef pb as PictureBox ) As Byte()
Dim ms As New System.IO.MemoryStream
With pb
.Image.Save(ms, pb.Image.RawFormat)
End With
[\code]
...

Dim a(0) as Byte Dim b(0) as Byte a = GetByteArrayFromImage2(picturebox1) b = GetByteArrayFromImage2(Picturebox2) [\code] 3. "Return outBytes" terminates your logic, the last two statements are never executed. The only way they would execute is if the above statement was in an If statement and the false path is followed.[code=vb]
Dim a(0) as Byte
Dim b(0) as Byte
a = GetByteArrayFromImage2(picturebox1)
b = GetByteArrayFromImage2(Picturebox2)
[\code]
3. "Return outBytes" terminates your logic, the last two statements are never executed. The only way they would execute is if the above statement was in an If statement and the false path is followed.

Edited 7 Years Ago by kplcjl: taking out exess pasted information

Sorry, I replied to the code snippet instead of your question. Read above to see my comments.

Edited 7 Years Ago by kplcjl: n/a

pls give the code that adds content of a single(not two) picture box and syntax that stores the image to a field in the table
also the code that displays the field from databsee to a form

Edited 6 Years Ago by deleodesanmi: typing errors