Hai,.., apa kabar Semua,q dapat pertanyaan dari temen ku nih, tentang radio button.
Dalam pengembaraan mencari coding tentang radio button pada VB.net q menemukan sebuah pencerahan untuk menyelesaikan masalah yang sedang q hadapi, Lets go...
q tuh pengen form seperti ini :
Dim tabel As OleDb.OleDbDataAdapter
Dim data As DataSet
Dim record As New BindingSource
Dim input As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call koneksi() //berkoneksi dengan database
Call tampilkandata() //kemudian menampilkandata yang telah di panggil di "sub tampilkandata()"
End Sub
' Private Sub RadioButton1_CheckedChanged(ByVal sender As Object, ByVal e As 'System.EventArgs) Handles RadioButton1.CheckedChanged
' txtcari.Focus()
' End Sub
End Class
Continue reading CATATAN kecil Kombinasi Pencarian dengan Radio Button dan Ms. Acces
Dalam pengembaraan mencari coding tentang radio button pada VB.net q menemukan sebuah pencerahan untuk menyelesaikan masalah yang sedang q hadapi, Lets go...
q tuh pengen form seperti ini :
Imports System.Data.OleDb
Public Class Form1
Public Class Form1
Dim tabel As OleDb.OleDbDataAdapter
Dim data As DataSet
Dim record As New BindingSource
Dim input As String
#Region "olahan"
Sub tampilkandata()
da = New OleDbDataAdapter("select*from DATAKU", conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "DATAKU")
DataGridView1.DataSource = (ds.Tables("DATAKU"))
DataGridView1.ReadOnly = True
End Sub
Sub tampilkandata()
da = New OleDbDataAdapter("select*from DATAKU", conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "DATAKU")
DataGridView1.DataSource = (ds.Tables("DATAKU"))
DataGridView1.ReadOnly = True
End Sub
//untuk mencari berdasarkan warkat ( Kode)
Sub searchrecordwarkat()
If Me.txtcari.Text = "" Then
MsgBox("Isikan Kata Kunci Pencarian", MsgBoxStyle.Information, "Peringatan")
Me.txtcari.Focus()
Exit Sub
End If
Try
da = New OleDbDataAdapter("Select warkat as [Warkat], nama as [Nama], no_seri as [Nomer Seri kupon], Alamat as [Alamat], no_hp as [Nomer HP], tgl_buka as [Tanggal Buka], nominal as [Nominal], jangka_waktu as [Jangka Waktu], jumlah_kupon as [Jumlah Kupon], tgl_tempo as [Tanggal Tempo] from DATAKU where warkat='" & txtcari.Text & "'", conn)
Dim transaksi As New DataTable
transaksi.Clear()
da.Fill(transaksi)
If transaksi.Rows.Count = Nothing Then
MsgBox("Data Tidak Ditemukan, Masukkan warkat Dengan Tepat !!!", MsgBoxStyle.Information, "Peringatan")
txtcari.Clear()
txtcari.Focus()
Exit Sub
End If
DataGridView1.DataSource = transaksi
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Peringatan")
End Try
End Sub
If Me.txtcari.Text = "" Then
MsgBox("Isikan Kata Kunci Pencarian", MsgBoxStyle.Information, "Peringatan")
Me.txtcari.Focus()
Exit Sub
End If
Try
da = New OleDbDataAdapter("Select warkat as [Warkat], nama as [Nama], no_seri as [Nomer Seri kupon], Alamat as [Alamat], no_hp as [Nomer HP], tgl_buka as [Tanggal Buka], nominal as [Nominal], jangka_waktu as [Jangka Waktu], jumlah_kupon as [Jumlah Kupon], tgl_tempo as [Tanggal Tempo] from DATAKU where warkat='" & txtcari.Text & "'", conn)
Dim transaksi As New DataTable
transaksi.Clear()
da.Fill(transaksi)
If transaksi.Rows.Count = Nothing Then
MsgBox("Data Tidak Ditemukan, Masukkan warkat Dengan Tepat !!!", MsgBoxStyle.Information, "Peringatan")
txtcari.Clear()
txtcari.Focus()
Exit Sub
End If
DataGridView1.DataSource = transaksi
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Peringatan")
End Try
End Sub
//Untuk mencari berdasarkan Nama
Sub searchrecordnama()
If Me.txtcari.Text = "" Then
MsgBox("Isikan Kata Kunci Pencarian", MsgBoxStyle.Information, "Peringatan")
Me.txtcari.Focus()
Exit Sub
End If
Try
da = New OleDbDataAdapter("Select warkat as [Warkat], nama as [Nama], no_seri as [Nomer Seri kupon], Alamat as [Alamat], no_hp as [Nomer HP], tgl_buka as [Tanggal Buka], nominal as [Nominal], jangka_waktu as [Jangka Waktu], jumlah_kupon as [Jumlah Kupon], tgl_tempo as [Tanggal Tempo] from DATAKU where nama like'%" & txtcari.Text & "%'", conn)
Dim transaksi As New DataTable
transaksi.Clear()
da.Fill(transaksi)
If transaksi.Rows.Count = Nothing Then
MsgBox("Data Tidak Ditemukan, Masukkan warkat Dengan Tepat !!!", MsgBoxStyle.Information, "Peringatan")
txtcari.Clear()
txtcari.Focus()
Exit Sub
End If
DataGridView1.DataSource = transaksi
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Peringatan")
End Try
End Sub
#End Region
//MULAI UNTUK BEKERJA MENAMPILKAN PADA FORM
If Me.txtcari.Text = "" Then
MsgBox("Isikan Kata Kunci Pencarian", MsgBoxStyle.Information, "Peringatan")
Me.txtcari.Focus()
Exit Sub
End If
Try
da = New OleDbDataAdapter("Select warkat as [Warkat], nama as [Nama], no_seri as [Nomer Seri kupon], Alamat as [Alamat], no_hp as [Nomer HP], tgl_buka as [Tanggal Buka], nominal as [Nominal], jangka_waktu as [Jangka Waktu], jumlah_kupon as [Jumlah Kupon], tgl_tempo as [Tanggal Tempo] from DATAKU where nama like'%" & txtcari.Text & "%'", conn)
Dim transaksi As New DataTable
transaksi.Clear()
da.Fill(transaksi)
If transaksi.Rows.Count = Nothing Then
MsgBox("Data Tidak Ditemukan, Masukkan warkat Dengan Tepat !!!", MsgBoxStyle.Information, "Peringatan")
txtcari.Clear()
txtcari.Focus()
Exit Sub
End If
DataGridView1.DataSource = transaksi
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Peringatan")
End Try
End Sub
#End Region
//MULAI UNTUK BEKERJA MENAMPILKAN PADA FORM
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If RadioButton1.Checked = True Then //JIKa RB1 di pilih Maka
searchrecordwarkat() //akan mensearchrecordwarkat()
DataGridView1.Refresh()
txtcari.Clear()
ElseIf RadioButton2.Checked = True Then //Jika salah dan RB2 di pilih Maka
searchrecordnama() //akan mensearchrecordnama()
DataGridView1.Refresh()
txtcari.Clear()
End If
End Sub
If RadioButton1.Checked = True Then //JIKa RB1 di pilih Maka
searchrecordwarkat() //akan mensearchrecordwarkat()
DataGridView1.Refresh()
txtcari.Clear()
ElseIf RadioButton2.Checked = True Then //Jika salah dan RB2 di pilih Maka
searchrecordnama() //akan mensearchrecordnama()
DataGridView1.Refresh()
txtcari.Clear()
End If
End Sub
//Yang akan tampil saat Pertama FORM Dijalankan
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call koneksi() //berkoneksi dengan database
Call tampilkandata() //kemudian menampilkandata yang telah di panggil di "sub tampilkandata()"
End Sub
' Private Sub RadioButton1_CheckedChanged(ByVal sender As Object, ByVal e As 'System.EventArgs) Handles RadioButton1.CheckedChanged
' txtcari.Focus()
' End Sub
End Class
CATATAN : JANGAN LUPA membuat koneksinya y..., dan panggil .
Saat mencari dengan Option Warkat / Kode yang di pilih
Saat mencari dengan Option Nama yang di pilih :