cara menampilkan foto gambar image picture secara otomatis dengan timer
Imports System.Data.OleDb
Public Class Form1
Dim CONN As OleDbConnection
Dim DA As OleDbDataAdapter
Dim DS As DataSet
Dim CMD As OleDbCommand
Dim DR As OleDbDataReader
Sub Koneksi()
CONN = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=dbkoperasi.mdb")
CONN.Open()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call Koneksi()
DA = New OleDbDataAdapter("select * from tblanggota", CONN)
DS = New DataSet
DA.Fill(DS)
DGV.DataSource = DS.Tables(0)
DGV.ReadOnly = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
On Error Resume Next
Dim counter As Integer = DGV.CurrentRow.Index + 1
Dim nextRow As DataGridViewRow
If counter = DGV.RowCount Then
nextRow = DGV.Rows(0)
Else
nextRow = DGV.Rows(counter)
End If
DGV.CurrentCell = nextRow.Cells(0)
nextRow.Selected = True
TextBox2.Text = DGV.Rows(counter).Cells(5).Value
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
On Error Resume Next
PictureBox1.Load(TextBox2.Text)
End Sub
End Class