Modul (Pendeklarasian Database)
Public con As New ADODB.Connection
Public rs As New ADODB.Recordset
Public sql As String
Public Sub connect()
con.ConnectionString = "Provider=MSDASQL.1;Password=;Persist Security Info=True;User ID=root;Data Source=stok"
con.Open
End Sub form load (eksekusi perintah pada database)
If con.State = adStateClosed Then
connect
End If
Script Buat nyimpan
* baris pertama = field pada database
* baris kedua values pada program
sql = "insert into barang (kd_brg,nm_brg,hrg_beli,hrg_jual,stok_awal,stok_sisa,tgl_input,bln_input,thn_input,keluar,tgl_expired ) " & _
"Values('" & Text1 & "','" & Text2 & "','" & Text3 & "','" & Text44 & "','" & Text5 & "','" & Text5 & "','" & Format(Text19, "yyyy-MM-dd") & "','" & Text22 & "','" & Text23 & "','" & Text41 & "','" & Format(DTPicker3, "yyyy-MM-dd") & "')"
con.Execute (sql)
Script Buat research Field
sql = "select * from barang where kd_brg='" & Text1.Text & "'"
Set rs = con.Execute(sql)
If Not rs.EOF Then
Text1 = rs!KD_BRG
Text2 = rs!NM_BRG
Else
Msgbox ("data tidak ada")
Text1.setfocus
End if
Script Buat delete Data
sql = "delete from barang where kd_brg= '" & Text1 & "'"
con.Execute (sql)
Script buat Edit (hapus + simpan)
sql = "update barang set hrg_jual='" & Text44 & "',nm_brg='" & Text2 & "' WHERE KD_BRG='" & Text1 & "'"
con.Execute (sql)
Script running text
Private Sub Timer1_Timer()
On Error Resume Next
If Label1.Visible = True Then
Label1.Visible = False
ElseIf Label1.Visible = False Then
Label1.Visible = True
End If
End Sub
Private Sub Timer2_Timer()
TEKS = Right(TEKS, Len(TEKS) - 1) & Left(TEKS, 1)
Label2.Caption = TEKS
End Sub
Private Sub Timer3_Timer()
Label3.Top = Label3.Top - 100
Me.Top = (Screen.Height - Me.Height) / 2
If Label3.Top <= 0 Then
Label3.Top = Label3.Top + 9000
End If
End Sub
Private Sub Timer4_Timer()
Label4.Top = Label4.Top + 100
Me.Top = (Screen.Height - Me.Height) / 2
If Label4.Top >= 7800 Then
Label4.Top = Label4.Top - 9000
End If
End Sub
letakan pada posisi general
Option Explicit
Dim TEKS As String
Script keluar
END
maaf kalo ada salah" gan...
Belum terlalu mahir Buat thread..
kalo ada ang mau di tanyakan Seputar VB ato MySql..
PM aja gan...