Lalu tambahkan Properties yaitu : Label , Textfield , listview dan command.Sehingga desain telah jadi seperti dibawah ini :
Lalu atur propertiesnya dan beri source coding berikut :
Dim stsimpan As Integer
Sub posisiawal()
Call control_active(False)
ListView1.Enabled = True
cmdadd.Enabled = True
cmdsave.Enabled = False
cmdedit.Enabled = True
cmdbatal.Enabled = False
cmddelete.Enabled = True
kosong
End Sub
Sub posisitambah()
Call control_active(True)
ListView1.Enabled = False
cmdadd.Enabled = False
cmdsave.Enabled = True
cmdedit.Enabled = False
cmdbatal.Enabled = True
cmddelete.Enabled = False
End Sub
Sub posisiedit()
Call control_active(True)
ListView1.Enabled = False
cmdadd.Enabled = False
cmdsave.Enabled = True
cmdedit.Enabled = False
cmdbatal.Enabled = True
cmddelete.Enabled = False
End Sub
Sub posisisimpan()
Call control_active(False)
ListView1.Enabled = True
cmdadd.Enabled = True
cmdsave.Enabled = True
cmdedit.Enabled = True
cmdbatal.Enabled = True
cmddelete.Enabled = True
End Sub
Sub posisibatal()
Call control_active(False)
ListView1.Enabled = True
cmdadd.Enabled = True
cmdsave.Enabled = True
cmdedit.Enabled = True
cmdbatal.Enabled = True
cmddelete.Enabled = True
End Sub
Private Sub cmdadd_Click()
Call posisitambah
stsimpan = 0
End Sub
Private Sub cmdbatal_Click()
Call posisibatal
Call kosong
End Sub
Private Sub cmdedit_Click()
Call cek_kosong
Call posisiedit
Call kosong
stsimpan = 1
End Sub
Private Sub cmdsave_Click()
If cek_kosong = True Then
Exit Sub
End If
Call posisiawal
If stsimpan = 0 Then
strsql = "insert into tabel"
MsgBox ("Data Telah Ditambah")
ElseIf stsimpan = 1 Then
strsql = "update into "
MsgBox ("Data Telah Diedit")
End If
End Sub
Private Sub Form_Load()
Call posisiawal
End Sub
Sub kosong()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
Sub control_active(x As Boolean)
Text1.Enabled = x
Text2.Enabled = x
Text3.Enabled = x
End Sub
Function cek_kosong() As Boolean
If (Text1.Text = "") Then
MsgBox "Isikan Kode Anda !"
Text1.SetFocus
cek_kosong = True
ElseIf (Text2.Text = "") Then
MsgBox "Isikan Nama Anda !"
Text2.SetFocus
cek_kosong = True
ElseIf (Text3.Text = "") Then
MsgBox "Isikan Alamat Anda !"
Text3.SetFocus
cek_kosong = True
Else
cek_kosong = False
End If
End Function
Finish , Program sederhana yang efisien ini bisa di jalankan :)
Silahkan mencoba yaa :DD
Tidak ada komentar:
Posting Komentar