Belajar relasi lagi,dan membaut form baru untuk coding yang lebih simple,
ini contoh form nya
1. buat form baru pada visual basic 6.0
2. buat field seperti contoh yang ada di bawah ini
3. setelah membuat field seperti di atas, ini lah saat nya coding
ini script coding nya
Dim stsimpan As Integer
Sub posisiawal()
Call control_aktif(False)
ListView1.Enabled = True
cmdtambah.Enabled = True
cmdkoreksi.Enabled = True
cmdsimpan.Enabled = False
cmdhapus.Enabled = True
cmdprint.Enabled = True
cmdkeluar.Enabled = True
cmdbatal.Enabled = False
Call kosong
End Sub
Sub tambah ()
Call control_aktif(True)
ListView1.Enabled = False
cmdsimpan.Enabled = True
cmdbatal.Enabled = True
cmdhapus.Enabled = False
cmdprint.Enabled = False
cmdkeluar.Enabled = False
cmdtambah.Enabled = False
cmdkoreksi.Enabled = False
End Sub
Sub koreksi()
Call control_aktif(True)
ListView1.Enabled = False
cmdsimpan.Enabled = True
cmdbatal.Enabled = True
cmdhapus.Enabled = False
cmdprint.Enabled = False
cmdkeluar.Enabled = False
cmdtambah.Enabled = False
cmdkoreksi.Enabled = False
End Sub
Sub simpan()
Call posisiawal
End Sub
Sub batal()
Call posisiawal
End Sub
Private Sub cmdbatal_Click()
Call batal
End Sub
Private Sub cmdkeluar_Click()
End
End Sub
Private Sub cmdkoreksi_Click()
Call koreksi
stsimpan = 1
End Sub
Private Sub cmdsimpan_Click()
If cek_kosong = True Then
Exit Sub
End If
Call simpan
Call posisiawal
If stsimpan = 0 Then
strsql = "insert into table"
MsgBox ("Tambah data baru")
ElseIf stsimpan = 1 Then
strsql = "insert into table"
MsgBox ("koreksi data")
End If
End Sub
Private Sub cmdtambah_Click()
Call tambah
Call kosong
stsimpan = 0
End Sub
Private Sub Form_Load()
Call posisiawal
End Sub
Sub kosong()
txtkode.Text = ""
txtnama.Text = ""
txtalamat.Text = ""
End Sub
Sub control_aktif(x As Boolean)
txtkode.Enabled = x
txtnama.Enabled = x
txtalamat.Enabled = x
End Sub
Function cek_kosong() As Boolean
If txtkode.Text = "" Then
MsgBox ("Kode harus di isi")
txtkode.SetFocus
cek_kosong = True
ElseIf txtnama.Text = "" Then
MsgBox ("nama harus di isi")
txtnama.SetFocus
cek_kosong = True
ElseIf txtalamat.Text = "" Then
MsgBox ("alamat harus di isi")
txtalamat.SetFocus
cek_kosong = True
Else
cek_kosong = False
End If
End Function
Catatan : UNTUK NAMA PRIVATE SUB MENGIKUTI NAMA COMMAND BUTTON NYA
selamat mencoba ya :)
0 Responses to "11-September-2012"
Posting Komentar