Você está na página 1de 3

Private Sub CMDTMBH_Click() Dim iRow As Long Dim ws As Worksheet Set ws = Worksheets("DATABASE") 'menemukan baris kosong pada database

siswa iRow = ws.Cells(Rows.Count, 1) _ .End(xlUp).Offset(1, 0).Row 'check untuk sebuah nis If Trim(Me.tnis.Value) = "" Then Me.tnis.SetFocus MsgBox "Masukan NIS terlebih dahulu" Exit Sub End If 'copy data ke database siswa ws.Cells(iRow, 1).Value = Me.tnis.Value ws.Cells(iRow, 2).Value = Me.tnama.Value ws.Cells(iRow, 3).Value = Me.tkelamin.Value ws.Cells(iRow, 4).Value = Me.tkelas.Value 'clear data siswa Me.tnis.Value = "" Me.tnama.Value = "" Me.tkelamin.Value = "" Me.tkelas.Value = "" Me.tnis.SetFocus End Sub Private Sub CMDTTP_Click() Unload Me End Sub Private Sub UserForm_QueryClose(Cancel As Integer, _ CloseMode As Integer) If CloseMode = vbFormControlMenu Then Cancel = True MsgBox "Gunakan Tombol TUTUP PROGRAM untuk Keluar" End If End Sub

Sub FORM() UserForm1.Show Sheets("sheet1").Select End Sub Private Sub bukasheet() Sheets("DATABASE").Select UserForm1.Show End Sub Private Sub cmdInput_Click() Set wsdatabase = Sheets("data") Dim Barisdatabase As Long

If txtNIS.Text = "" Then MsgBox "NOMOR masih kosong", vbOKOnly txtNIS.SetFocus Exit Sub ElseIf txtNAMA.Text = "" Then MsgBox "NAMA masih kosong", vbOKOnly txtNAMA.SetFocus Exit Sub Exit Sub End If With wsdatabase Barisdatabase = .Cells(.Rows.Count, "A"). _ End(xlUp).Offset(0, 1).Row '--- data input .Cells(Barisdatabase .Cells(Barisdatabase .Cells(Barisdatabase .Cells(Barisdatabase .Cells(Barisdatabase .Cells(Barisdatabase .Cells(Barisdatabase .Cells(Barisdatabase .Cells(Barisdatabase .Cells(Barisdatabase .Cells(Barisdatabase .Cells(Barisdatabase .Cells(Barisdatabase .Cells(Barisdatabase txtNIS.Text = "" txtNAMA.Text = "" cboJEKA.Text = "" txtTemLahi.Text = "" txtTgl.Text = "" cboBULAN.Text = "" txtTahlah.Text = "" txtDus.Text = "" txtRT.Text = "" txtDes.Text = "" txtCam.Text = "" txtBup.Text = "" txtProp.Text = "" txtHP.Text = "" MsgBox "Data sudah disimpan", vbOKOnly txtNIS.SetFocus End With End Sub + + + + + + + + + + + + + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1).Value = txtNIS.Text 2).Value = txtNAMA.Text 3).Value = cboJEKA.Text 4).Value = txtTemLahi.Text 5).Value = txtTgl.Text 6).Value = cboBULAN.Text 7).Value = txtTahlah.Text 8).Value = txtDus.Text 9).Value = txtRT.Text 10).Value = txtDes.Text 11).Value = txtCam.Text 12).Value = txtBup.Text 13).Value = txtProp.Text 14).Value = txtHP.Text

Private Sub cmdBatal_Click() txtNIS.Text = "" txtNAMA.Text = "" cboJEKA.Text = "" txtTemLahi.Text = "" txtTgl.Text = "" cboBULAN.Text = "" txtTahlah.Text = "" txtDus.Text = "" txtRT.Text = "" txtDes.Text = "" txtCam.Text = "" txtBup.Text = "" txtProp.Text = "" txtHP.Text = "" End Sub Private Sub UserForm_Initialize() With Me .cboJEKA.AddItem "Laki-laki" .cboJEKA.AddItem "Perempuan" End With With cboBULAN .AddItem "Januari" .AddItem "Februari" .AddItem "Maret" .AddItem "April" .AddItem "Mei" .AddItem "Juni" .AddItem "Juli" .AddItem "Agustus" .AddItem "September" .AddItem "Oktober" .AddItem "November" .AddItem "Desember" End With End Sub 'With Selection.Validation .Delete .Add Type:=xlValidateCustom, AlertStyle:=xlValidAlertStop, Operator:= _ xlBetween, Formula1:="=COUNTIF(A$2:A$400;A5)<=1" .IgnoreBlank = True .InCellDropdown = True .InputTitle = "" .ErrorTitle = "No Pendaftaran ganda" .InputMessage = "" .ErrorMessage = "No Pendaftaran Sudah Pernah Di Input" .ShowInput = True .ShowError = True End With txt_nopendaftara.Select End Sub

Você também pode gostar