Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub TombolTambah_Click()
- Dim iRow As Long
- DIm Path As String: Path = ThisWorkbook.Path & "\FotoSiswa\"
- Dim Ws As Worksheet: Set Ws = Worksheets("Sheet1")
- iRow = Ws.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).Row
- If WorksheetFunction.CountIf(Ws.Range("B2", Ws.Cells(iRow - 1, 2)), Me.TextBox1.Value) > 0 Then
- MsgBox "No Induk Sudah ada dalam Database, Silakan Lakukan edit jika ada kesalahan", vbCritical
- Exit Sub
- End If
- If CheckKosong then
- With Ws
- .Cells(iRow, 2).Value = TextBox1.Value
- .Cells(iRow, 3).Value = TextBox2.Value
- .Cells(iRow, 4).Value = TextBox3.Value
- .Cells(iRow, 5).Value = TextBox4.Value
- .Cells(iRow, 6).Value = TextBox5.Value
- .Cells(iRow, 7).Value = TextBox6.Value
- .Cells(iRow, 8).Value = TextBox7.Value
- .Cells(iRow, 9).Value = Path & Me.TextBox1.Value & ".jpg"
- Set myPict = Ws.Cells(iRow, 10).Parent.Pictures.Insert(Ws.Cells(iRow, 9).Value)
- myPict.Top = Ws.Cells(iRow, 10).Top
- myPict.Width = Ws.Cells(iRow, 10).Width
- myPict.Height = Ws.Cells(iRow, 10).Height
- myPict.Left = Ws.Cells(iRow, 10).Left
- myPict.Placement = xlMoveAndSize
- end With
- SavePicture UserForm1.Image1.Picture, Path & UserForm1.TextBox1.Value & ".jpg"
- MsgBox "Data berhasil ditambahkan ", vbInformation, "Info"
- Call BERSIHKAN
- Call ListDSiswa
- end if
- End Sub
- Function CheckKosong() as boolean
- Dim Pesan as string
- If Trim(Me.TextBox1.Value) = vbNullString Then
- TextBox1.SetFocus
- pesan = "Silakan Masukan No Induk"
- CheckKosong = False
- elseIf Trim(Me.TextBox2.Value) = vbNullString Then
- TextBox2.SetFocus
- Pesan = "Silakan Masukan NIS"
- CheckKosong = False
- elseIf Trim(Me.TextBox3.Value) = vbNullString Then
- TextBox3.SetFocus
- Pesan = "Silakan Masukan NAMA"
- CheckKosong = False
- ElseIf Trim(Me.TextBox4.Value) = vbNullString Then
- TextBox4.SetFocus
- Pesan = "Silakan Masukan Jenis Kelamin"
- CheckKosong = False
- ElseIf Trim(Me.TextBox5.Value) = vbNullString Then
- TextBox5.SetFocus
- Pesan = "Silakan Masukan Tempat Lahir"
- CheckKosong = False
- ElseIf Trim(Me.TextBox6.Value) = vbNullString Then
- TextBox6.SetFocus
- Pesan = "Silakan Masukan Tanggal Lahir"
- CheckKosong = False
- ElseIf Trim(Me.TextBox7.Value) = vbNullString Then
- TextBox7.SetFocus
- Pesan = "Silakan Masukan Kelas"
- CheckKosong = False
- else
- checkKosong = True
- End If
- msgbox Pesan
- end Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement