Public Class Frmip
Dim nobkn, bkn1 As Byte
Dim hasil, kelamin, tahun, bulan, tgl, tahun2, bulan2, grup As String
Private Sub frmip_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
texttotok.MaxLength = 18
Select Case e.KeyCode
Case Keys.F3
If Microsoft.VisualBasic.Mid(texttotok.Text, 5, 2) = "" Then
MessageBox.Show("kosong", "error pengisian", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf Microsoft.VisualBasic.Left(texttotok.Text, 4) = "" Then
MessageBox.Show("kosong", "error pengisian", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf Microsoft.VisualBasic.Mid(texttotok.Text, 7, 2) = "" Then
MessageBox.Show("kosong", "error pengisian", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf Microsoft.VisualBasic.Mid(texttotok.Text, 7, 2) < 1 Then
MessageBox.Show("kosong", "error pengisian", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf Microsoft.VisualBasic.Mid(texttotok.Text, 5, 2) < 1 Then
MessageBox.Show("kosong", "error pengisian", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf Microsoft.VisualBasic.Left(texttotok.Text, 4) < 1 Then
MessageBox.Show("kosong", "error pengisian", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf Microsoft.VisualBasic.Left(texttotok.Text, 4) > 2014 Then
MsgBox("tahun lahir ditentukan kurang dari tahun 2014 " & vbNewLine & "Pengisian Deret Pertama - Keempat", MsgBoxStyle.Question)
ElseIf Microsoft.VisualBasic.Left(texttotok.Text, 4) < 1950 Then
MsgBox("NIP dibuat pertama tahun 1945 dengan 4 posisi di deret pertama diatas tahun 1945" & vbNewLine & "periksa pengisian deret pertama sampai keempat", MsgBoxStyle.Question)
ElseIf Microsoft.VisualBasic.Mid(texttotok.Text, 5, 2) > 12 Then
texttotok.Select()
MsgBox("salah pengisian deret kelima dan keenam adalah bulan" & vbNewLine & "jumlah Maximal bulan 12, periksa input deret kelima dan keenam", MsgBoxStyle.Information)
ElseIf Microsoft.VisualBasic.Mid(texttotok.Text, 5, 2) < 1 Then
MsgBox("salah pengisian deret kelima dan keenam adalah bulan" & vbNewLine & "jumlah Minimal bulan 1, periksa input deret kelima dan keenam", MsgBoxStyle.Information)
ElseIf Microsoft.VisualBasic.Mid(texttotok.Text, 7, 2) > 31 And Microsoft.VisualBasic.Mid(texttotok.Text, 5, 2) = 1 Then
MsgBox("salah pengisian deret ketujuh dan kedelapan adalah tanggal" & vbNewLine & "melebihi batas tangggal", MsgBoxStyle.Information)
ElseIf Microsoft.VisualBasic.Mid(texttotok.Text, 7, 2) > 31 And Microsoft.VisualBasic.Mid(texttotok.Text, 5, 2) = 3 Then
MsgBox("salah pengisian deret ketujuh dan kedelapan adalah tanggal" & vbNewLine & "melebihi batas tanggal", MsgBoxStyle.Information)
ElseIf Microsoft.VisualBasic.Mid(texttotok.Text, 7, 2) > 30 And Microsoft.VisualBasic.Mid(texttotok.Text, 5, 2) = 4 Then
MsgBox("salah pengisian deret ke-7 dan 8 adalah tanggal" & vbNewLine & "melebihi btas tanggal", MsgBoxStyle.Information)
ElseIf Microsoft.VisualBasic.Mid(texttotok.Text, 7, 2) > 31 And Microsoft.VisualBasic.Mid(texttotok.Text, 5, 2) = 5 Then
MsgBox("salah pengisian deret ke-7 dan 8 adalah tanggal" & vbNewLine & "melebihi batas tanggal", MsgBoxStyle.Information)
ElseIf Microsoft.VisualBasic.Mid(texttotok.Text, 7, 2) > 30 And Microsoft.VisualBasic.Mid(texttotok.Text, 5, 2) = 6 Then
MsgBox("salah pengisian deret ke-7 dan 8 adalah tanggal" & vbNewLine & "melebihi batas tanggal", MsgBoxStyle.Information)
ElseIf Microsoft.VisualBasic.Mid(texttotok.Text, 7, 2) > 31 And Microsoft.VisualBasic.Mid(texttotok.Text, 5, 2) = 7 Then
MsgBox("salah pengisian deret ke-7 dan 8 adalah tanggal" & vbNewLine & "melebihi batas tanggal", MsgBoxStyle.Information)
ElseIf Microsoft.VisualBasic.Mid(texttotok.Text, 7, 2) > 31 And Microsoft.VisualBasic.Mid(texttotok.Text, 5, 2) = 8 Then
MsgBox("salah pengisian deret ke-7 dan 8 adalah tanggal" & vbNewLine & "melebihi batas tanggal", MsgBoxStyle.Information)
ElseIf Microsoft.VisualBasic.Mid(texttotok.Text, 7, 2) > 30 And Microsoft.VisualBasic.Mid(texttotok.Text, 5, 2) = 9 Then
MsgBox("salah pengisian deret ke-7 dan 8 adalah tanggal" & vbNewLine & "melebihi batas tanggal", MsgBoxStyle.Information)
ElseIf Microsoft.VisualBasic.Mid(texttotok.Text, 7, 2) > 31 And Microsoft.VisualBasic.Mid(texttotok.Text, 5, 2) = 10 Then
MsgBox("salah pengisian deret ke-7 dan 8 adalah tanggal" & vbNewLine & "melebihi batas tanggal", MsgBoxStyle.Information)
ElseIf Microsoft.VisualBasic.Mid(texttotok.Text, 7, 2) > 30 And Microsoft.VisualBasic.Mid(texttotok.Text, 5, 2) = 11 Then
MsgBox("salah pengisian deret ke-7 dan 8 adalah tanggal" & vbNewLine & "melibihi batas maksimal", MsgBoxStyle.Information)
ElseIf Microsoft.VisualBasic.Mid(texttotok.Text, 7, 2) > 31 And Microsoft.VisualBasic.Mid(texttotok.Text, 5, 2) = 12 Then
MsgBox("salah pengisian deret ke-7 dan 8 adalah tanggal" & vbNewLine & "melebihi batas maksimal", MsgBoxStyle.Information)
ElseIf Microsoft.VisualBasic.Left(texttotok.Text, 4) Mod 4 = 0 And Microsoft.VisualBasic.Mid(texttotok.Text, 5, 2) = 2 And Microsoft.VisualBasic.Mid(texttotok.Text, 7, 2) > 29 Then
MsgBox("salah pengisian deret ke-7 dan 8 adalah tanggal" & vbNewLine & "melebihi batas maksimal", MsgBoxStyle.Information)
ElseIf Microsoft.VisualBasic.Left(texttotok.Text, 4) Mod 4 = 0 = False And Microsoft.VisualBasic.Mid(texttotok.Text, 5, 2) = 2 And Microsoft.VisualBasic.Mid(texttotok.Text, 7, 2) > 28 Then
MsgBox("salah pengisian deret ke-7 dan 8 adalah tanggal" & vbNewLine & "melebihi batas maksimal", MsgBoxStyle.Information)
ElseIf Microsoft.VisualBasic.Mid(texttotok.Text, 7, 2) < 1 Then
MsgBox("Deret ke-7 dan 8 berisi tanggal" & vbNewLine & "Tanggal Minimal 1, Periksa inputan anda deret ke-7 dan 8", MsgBoxStyle.Information)
ElseIf MessageBox.Show("tanggal lahir anda:" & Microsoft.VisualBasic.Left(texttotok.Text, 4) & "/" & Microsoft.VisualBasic.Mid(texttotok.Text, 5, 2) & "/" & Microsoft.VisualBasic.Mid(texttotok.Text, 7, 2), "tanggal lahir") Then
End If
Case Keys.F4
If Microsoft.VisualBasic.Mid(texttotok.Text, 13, 2) = "" Then
MessageBox.Show("kosong", "error pengisian", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf Microsoft.VisualBasic.Mid(texttotok.Text, 13, 2) < 1 Then
MessageBox.Show("salah pengisian", "error pengisian", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf Microsoft.VisualBasic.Mid(texttotok.Text, 13, 2) > 12 Then
MessageBox.Show("salah pengisian", "error pengisian", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf MessageBox.Show("Tahun dan bulan pengangkatan : " & Microsoft.VisualBasic.Mid(texttotok.Text, 9, 4) & vbCrLf & "/" & Microsoft.VisualBasic.Mid(texttotok.Text, 13, 2), "keterangan pengankatan", MessageBoxButtons.OK, MessageBoxIcon.Information) Then
End If
Case Keys.F5
hasil = Microsoft.VisualBasic.Mid(texttotok.Text, 15, 1)
If Microsoft.VisualBasic.Mid(texttotok.Text, 15, 1) = "" Then
MessageBox.Show("kosong", "error pengisian", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf hasil = 1 Then
MessageBox.Show("laki-laki", "jenis kelamin", MessageBoxButtons.OK, MessageBoxIcon.Information)
ElseIf hasil = 2 Then
MessageBox.Show("perempuan", "jenis kelamin", MessageBoxButtons.OK, MessageBoxIcon.Information)
ElseIf hasil > 2 Then
MessageBox.Show("salah", "pengisian salah", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf hasil = 0 Then
MessageBox.Show("salah", "pengisian salah", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
Case Keys.F6
If Microsoft.VisualBasic.Mid(texttotok.Text, 16, 3) = "" Then
MessageBox.Show("pengisian salah", "error pengisian", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf Microsoft.VisualBasic.Mid(texttotok.Text, 16, 3) < 1 Then
MessageBox.Show("pengisian salah", "error pengisian", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIf MessageBox.Show("nomor pengangkatan:" & Microsoft.VisualBasic.Mid(texttotok.Text, 16, 3), "nomor urut anda", MessageBoxButtons.OK, MessageBoxIcon.Information) Then
End If
Case Keys.Delete
texttotok.Text = ""
Case Keys.End
Close()
End Select
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.KeyPreview = True
End Sub
Private Sub texttotok_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles texttotok.KeyPress
If (InStr("0123456789", e.KeyChar) = 0) And (e.KeyChar <> Chr(8)) Then e.KeyChar = Chr(0)
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles texttotok.TextChanged
If Not IsNumeric(texttotok.Text) Then
texttotok.Text = ""
End If
End Sub
End Class
Tidak ada komentar:
Posting Komentar