'Aplikasi Pemilu Sederhana VB 6.0 & Acses.mdb
'KODE====================================================
'Komentar email ke: axkhan23@gmail.com
'ALEX W K :)
Dim db As ADODB.Connection
Dim rs As ADODB.Recordset
Dim db1 As ADODB.Connection
Dim rs1 As ADODB.Recordset
Private Sub Check1_Click()
If Check1.Value = 1 Then
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Else
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
End If
End Sub
Private Sub Command1_Click()
On Error Resume Next
Adodc1.ConnectionString
= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path &
"\dbpemilu.mdb" & ";Persist Security Info=False"
Command1.Enabled = False
Text3 = 2
'=======================
Set db = New ADODB.Connection
Set rs = New ADODB.Recordset
db.ConnectionString
= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path &
"\dbpemilu.mdb" & ";Persist Security Info=False"
db.Open "", ""
a = "select * from Table1"
rs.Open a, db, adOpenDynamic, adLockOptimistic, adCmdText
rs.Requery
Set db1 = New ADODB.Connection
Set rs1 = New ADODB.Recordset
db1.ConnectionString
= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path &
"\dbpemilu.mdb" & ";Persist Security Info=False"
db1.Open "", ""
b = "select * from Table1"
rs1.Open b, db1, adOpenDynamic, adLockOptimistic, adCmdText
rs1.Requery
'==========================
Text2 = "Jokowi-Jusuf"
Text1 = 1
a = MsgBox("Apakah anda yakin JOKOWI JUSUF... ", vbYesNo, "Pesan")
If a = vbYes Then
Set rs1 = db1.Execute("select * from table1 where nama_kandidat='" & Text2.Text & "'")
If rs1.EOF Then
Set rs = db.Execute("update table1 " & _
"set jumlah_suara ='" & Text1.Text & "'" & _
" where nama_kandidat='" & Text2.Text & "'")
'Pouse 1
Timer1.Enabled = True
Exit Sub
Else
num = rs1!jumlah_suara
Text1 = num + 1
End If
Set rs = db.Execute("update table1 " & _
"set jumlah_suara ='" & Text1.Text & "'" & _
" where nama_kandidat='" & Text2.Text & "'")
MsgBox "Data telah terupdate....!", vbInformation, "Pesan"
Adodc1.Refresh
DataGrid1.Refresh
bersih
'Pouse 1
Timer1.Enabled = True
Else
Timer1.Enabled = True
End If
End Sub
Private Sub Command2_Click()
On Error Resume Next
Adodc1.ConnectionString
= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path &
"\dbpemilu.mdb" & ";Persist Security Info=False"
Command2.Enabled = False
Text3 = 1
'=======================
Set db = New ADODB.Connection
Set rs = New ADODB.Recordset
db.ConnectionString
= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path &
"\dbpemilu.mdb" & ";Persist Security Info=False"
db.Open "", ""
a = "select * from Table1"
rs.Open a, db, adOpenDynamic, adLockOptimistic, adCmdText
rs.Requery
Set db1 = New ADODB.Connection
Set rs1 = New ADODB.Recordset
db1.ConnectionString
= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path &
"\dbpemilu.mdb" & ";Persist Security Info=False"
db1.Open "", ""
b = "select * from Table1"
rs1.Open b, db1, adOpenDynamic, adLockOptimistic, adCmdText
rs1.Requery
'==========================
Text2 = "Prabowo-Hatta"
Text1 = 1
a = MsgBox("Apakah anda yakin PRABOWO HATTA... ", vbYesNo, "Pesan")
If a = vbYes Then
Set rs1 = db1.Execute("select * from table1 where nama_kandidat='" & Text2.Text & "'")
If rs1.EOF Then
Set rs = db.Execute("update table1 " & _
"set jumlah_suara ='" & Text1.Text & "'" & _
" where nama_kandidat='" & Text2.Text & "'")
' Pouse 2
Timer1.Enabled = True
Exit Sub
Else
num = rs1!jumlah_suara
Text1 = num + 1
End If
Set rs = db.Execute("update table1 " & _
"set jumlah_suara ='" & Text1.Text & "'" & _
" where nama_kandidat='" & Text2.Text & "'")
MsgBox "Data telah terupdate....!", vbInformation, "Pesan"
Adodc1.Refresh
DataGrid1.Refresh
bersih
'Pouse 1
Timer1.Enabled = True
Else
Timer1.Enabled = True
End If
End Sub
Private Sub Command3_Click()
On Error Resume Next
ALX
= MsgBox("ANDA INGIN MERESET JUMLAH SUARA KE O....! PILIH YES UNTUK
MELANJUTKAN DAN NO UNTUK BATAL....!", vbYesNo, "PERINGATAN")
If ALX = vbYes Then
Text2 = "Prabowo-Hatta"
Text1 = 0
Set rs = db.Execute("update table1 " & _
"set jumlah_suara ='" & Text1.Text & "'" & _
" where nama_kandidat='" & Text2.Text & "'")
Pouse 1
Text2 = "Jokowi-Jusuf"
Text1 = 0
Set rs = db.Execute("update table1 " & _
"set jumlah_suara ='" & Text1.Text & "'" & _
" where nama_kandidat='" & Text2.Text & "'")
MsgBox "Data telah terupdate....!", vbInformation, "Pesan"
bersih
Text4 = 0
Text5 = 0
Adodc1.Refresh
DataGrid1.Refresh
Else
End If
End Sub
Private Sub Command4_Click()
On Error Resume Next
ALX = MsgBox("ANDA MELAKUKAN PROSES PENAMBAHAN...!, INGIN DILANJUTKAN...?", vbYesNo, "PERINGATAN")
If ALX = vbYes Then
Text2 = "Prabowo-Hatta"
Text1 = 0
Set rs = db.Execute("select * from table1 where nama_kandidat='" & Text2.Text & "'")
If rs.EOF Then
Else
Text1 = rs!jumlah_suara
End If
Text1 = Val(Text1.Text) + Val(Text6.Text)
Set rs = db.Execute("update table1 " & _
"set jumlah_suara ='" & Text1.Text & "'" & _
" where nama_kandidat='" & Text2.Text & "'")
MsgBox "Data telah terupdate....!", vbInformation, "Pesan"
bersih
Adodc1.Refresh
DataGrid1.Refresh
Else
End If
End Sub
Private Sub Command5_Click()
On Error Resume Next
ALX = MsgBox("ANDA MELAKUKAN PROSES PENAMBAHAN...!, INGIN DILANJUTKAN...?", vbYesNo, "PERINGATAN")
If ALX = vbYes Then
Text2 = "Jokowi-Jusuf"
Text1 = 0
Set rs = db.Execute("select * from table1 where nama_kandidat='" & Text2.Text & "'")
If rs.EOF Then
Else
Text1 = rs!jumlah_suara
End If
Text1 = Val(Text1.Text) + Val(Text7.Text)
Set rs = db.Execute("update table1 " & _
"set jumlah_suara ='" & Text1.Text & "'" & _
" where nama_kandidat='" & Text2.Text & "'")
MsgBox "Data telah terupdate....!", vbInformation, "Pesan"
bersih
Adodc1.Refresh
DataGrid1.Refresh
Else
End If
End Sub
Private Sub Command6_Click()
'On Error Resume Next
Text2 = "Jokowi-Jusuf"
Set dbrs = New ADODB.Connection
Set rsrs = New ADODB.Recordset
dbrs.ConnectionString
= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path &
"\dbpemilu.mdb" & ";Persist Security Info=False"
dbrs.Open "", ""
ars = "select * from Table1"
rsrs.Open ars, dbrs, adOpenDynamic, adLockOptimistic, adCmdText
rsrs.Requery
Set rsrs = dbrs.Execute("select * from table1 where nama_kandidat='" & Text2.Text & "'")
If rsrs.EOF Then
If Text2 = "Jokowi-Jusuf" Then
Text5 = rsrs!jumlah_suara
Else
Text4 = rsrs!jumlah_suara
End If
Else
If Text2 = "Jokowi-Jusuf" Then
Text5 = rsrs!jumlah_suara
Else
Text4 = rsrs!jumlah_suara
End If
End If
Text2.Text = ""
End Sub
Private Sub Command7_Click()
Text2 = "Prabowo-Hatta"
Set dbrst1 = New ADODB.Connection
Set rsrst1 = New ADODB.Recordset
dbrst1.ConnectionString
= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path &
"\dbpemilu.mdb" & ";Persist Security Info=False"
dbrst1.Open "", ""
arrst1 = "select * from Table1"
rsrst1.Open arrst1, dbrst1, adOpenDynamic, adLockOptimistic, adCmdText
rsrst1.Requery
Set rsrst1 = dbrst1.Execute("select * from table1 where nama_kandidat='" & Text2.Text & "'")
If rsrst1.EOF Then
If Text2 = "Jokowi-Jusuf" Then
Text5 = rsrst1!jumlah_suara
Else
Text4 = rsrst1!jumlah_suara
End If
Else
If Text2 = "Jokowi-Jusuf" Then
Text5 = rsrst1!jumlah_suara
Else
Text4 = rsrst1!jumlah_suara
End If
End If
End Sub
Private Sub Form_Load()
On Error GoTo Alex_W_K
Set db = New ADODB.Connection
Set rs = New ADODB.Recordset
db.ConnectionString
= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path &
"\dbpemilu.mdb" & ";Persist Security Info=False"
db.Open "", ""
a = "select * from Table1"
rs.Open a, db, adOpenDynamic, adLockOptimistic, adCmdText
rs.Requery
Set db1 = New ADODB.Connection
Set rs1 = New ADODB.Recordset
db1.ConnectionString
= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path &
"\dbpemilu.mdb" & ";Persist Security Info=False"
db1.Open "", ""
b = "select * from Table1"
rs1.Open b, db1, adOpenDynamic, adLockOptimistic, adCmdText
rs1.Requery
Text1 = ""
Text2 = ""
Text3 = ""
Check1.Value = 1
Exit Sub
Alex_W_K:
MsgBox "Koneksi database.....!/ Periksa apakah file database sudah terkopi atw belum....", vbInformation, "Pesan"
End Sub
Sub bersih()
On Error Resume Next
Set rs = db.Execute("select * from table1 where nama_kandidat='" & Text2.Text & "'")
If rs.EOF Then
If Text2 = "Jokowi-Jusuf" Then
Text5 = rs!jumlah_suara
Else
Text4 = rs!jumlah_suara
End If
Else
If Text2 = "Jokowi-Jusuf" Then
Text5 = rs!jumlah_suara
Else
Text4 = rs!jumlah_suara
End If
End If
Text1 = ""
Text2 = ""
Text3 = ""
Text1.SetFocus
Adodc1.ConnectionString
= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path &
"\dbpemilu.mdb" & ";Persist Security Info=False"
DataGrid1.Refresh
End Sub
Sub Pouse(angka)
Dim pos As Integer
Tim = Timer
Do
If Timer - Tim > angka Then Exit Sub
pos = DoEvents()
Loop
End Sub
Private Sub Text3_Change()
Label4.Caption = Text3.Text
End Sub
Private Sub Text4_Change()
chrt.Row = 1
chrt.Data = Text4.Text
End Sub
Private Sub Text5_Change()
chrt.Row = 2
chrt.Data = Text5.Text
End Sub
Private Sub Timer1_Timer()
Adodc1.Refresh
DataGrid1.Refresh
Pouse 1
Command1.Enabled = True
Command2.Enabled = True
End Sub
Tampilan Aplikasi Desktop :
Script & Coding
Minggu, 19 Februari 2017
Jumat, 09 September 2016
Toast, ImageButton, OnClickListener : Eclipse ADT
script untuk layout : MyToast/res/layout/activity_my_toast.xml
=============================================================
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MyToast" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<ImageButton
android:id="@+id/btShow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="43dp"
android:src="@drawable/ic_launcher" />
</RelativeLayout>
java class activity : MyToast/src/MyToast.java
=========================================
package com.example.mytoast;
import android.os.Bundle;
import android.app.Activity;
import android.view.Gravity;
import android.view.Menu;
import android.view.View;
import android.widget.ImageButton;
import android.widget.Toast;
public class MyToast extends Activity {
ImageButton btShow;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_toast);
myToast();
}
public void myToast(){
btShow=(ImageButton)findViewById(R.id.btShow);
btShow.setOnClickListener(new ImageButton.OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Toast MYtoast=Toast.makeText(getApplicationContext(), "Message",Toast.LENGTH_LONG);
MYtoast.setDuration(100);
MYtoast.setGravity(Gravity.CENTER, 0, 0);
MYtoast.show();
}
});
}
}
==========================================================================
=============================================================
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MyToast" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<ImageButton
android:id="@+id/btShow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="43dp"
android:src="@drawable/ic_launcher" />
</RelativeLayout>
java class activity : MyToast/src/MyToast.java
=========================================
package com.example.mytoast;
import android.os.Bundle;
import android.app.Activity;
import android.view.Gravity;
import android.view.Menu;
import android.view.View;
import android.widget.ImageButton;
import android.widget.Toast;
public class MyToast extends Activity {
ImageButton btShow;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_toast);
myToast();
}
public void myToast(){
btShow=(ImageButton)findViewById(R.id.btShow);
btShow.setOnClickListener(new ImageButton.OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Toast MYtoast=Toast.makeText(getApplicationContext(), "Message",Toast.LENGTH_LONG);
MYtoast.setDuration(100);
MYtoast.setGravity(Gravity.CENTER, 0, 0);
MYtoast.show();
}
});
}
}
==========================================================================
Selasa, 21 Juni 2016
Koneksi dan Manipulasi Data dengan MYSQL dan VB.NET
Penggalan Coding berikut untuk melakukan koneksi ke database mysql, Tetapi sebelumnya harus menambahkan referensi konektor mysql. (menambahkan komponen ke framework) dan__________________________________________________________________
'paling atas jendela koding
Imports MySql.Data.MySqlClient
Imports System.Data
Imports Microsoft.Reporting.WinForms.ReportDataSource
__________________________________________________________________
__________________________________________________________________
'di paste ke event button click/form load/sub atau sesuaikan dengan algoritma yang digunakan
Dim constr As String = "Data Source=localhost;user id=root;password=;database=dbmhs"
Dim koneksi As New MySqlConnection(constr)
koneksi.Open()
'tampil()
__________________________________________________________________
'Simpan ke database
__________________________________________________________________
Dim cmd As New MySqlCommand
Dim query As String = "insert into mahasiswa(nama,nis,nohp)values('" & txt1.Text & "','" & txt2.Text & "','" & txt3.Text & "');"
cmd.Connection = koneksi
cmd.CommandText = query
cmd.ExecuteNonQuery()
__________________________________________________________________
Jumat, 10 Juni 2016
Sekilas PHP MYSQL dan APACHE
PHP : Merupakan bahasa script yang berfungsi untuk membuat web yang dinamis $Server-side
MYSQL : Merupakan aplikasi manajemen database (DBMS) yang open-source. dalam pemanfaatannya
dapat menggunakan tools berbasis windows dan teks(menggunakan Struktur Query
Language-SQL)
APACHE : Aplikasi web server yang berfungsi merespon request dari client memproses dan mengirim
kembali ke client
MYSQL : Merupakan aplikasi manajemen database (DBMS) yang open-source. dalam pemanfaatannya
dapat menggunakan tools berbasis windows dan teks(menggunakan Struktur Query
Language-SQL)
APACHE : Aplikasi web server yang berfungsi merespon request dari client memproses dan mengirim
kembali ke client
Langganan:
Postingan (Atom)