Jollyyy100 0 Junior Poster in Training

Hi, i want to know if its possible to bring upon many pictures in a single picturebox and navigating it. So far i have done the coding but when i run the program i cant see the picture being displayed following are my codes, and please help if theres any error or if u got a better solution:

Imports System.Data.OleDb
Imports System.IO

Public Class StaffForm1
    Dim conn As New OleDb.OleDbConnection
    Dim DA As OleDb.OleDbDataAdapter
    Dim DS As New DataSet
    Dim counter As Integer

    Private Sub StaffForm1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\User\Desktop\Payroll_System\PDatabase.mdb"

        DA = New OleDb.OleDbDataAdapter("Select * from Pictures", conn)


        counter = 0

        Me.PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        PictureBox1.Image = GetImageFromByteArray(DS.Tables(0).Rows.Item(counter).Item(0))

        If counter < Me.DS.Tables(0).Rows.Count - 1 Then

            counter += 1

        End If
    End Sub
    Private Function GetImageFromByteArray(ByVal picData As Byte()) As Image
        If picData Is Nothing Then
            Return Nothing
        End If

        ' is this is an embedded object? 
        Dim bmData As Integer = IIf((picData(0) = 21 AndAlso picData(1) = 28), 78, 0)

        ' load the picture 
        Dim img As Image = Nothing
            Dim ms As New IO.MemoryStream(picData, bmData, picData.Length - bmData)
            img = Image.FromStream(ms)
        End Try

        ' return what we got 
        Return img

    End Function

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        PictureBox1.Image = GetImageFromByteArray(DS.Tables(0).Rows.Item(counter).Item(0))

        If counter > 0 Then

            counter -= 1

        End If

    End Sub

End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.