Jumat, 19 Juli 2013

program sederhana pencari nilai IPK

 
------------------------------------------Source Code FORM----------------------------------------------------
Private Sub Command5_Click()
Unload Me
End Sub

Private Sub Form_Load()
koneksi
Adodc1.ConnectionString = Conn.ConnectionString
Adodc1.RecordSource = "select * from mahasiswa"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
Nim.Enabled = False
Nama.Enabled = False
Tugas.Enabled = False
UTS.Enabled = False
UAS.Enabled = False
Rata.Enabled = False
Grade.Enabled = False
Command4.Visible = False
End Sub

Private Sub Command1_Click()
  Adodc1.Recordset.AddNew
  Me.Nim.Text = ""
  Me.Nama.Text = ""
  Me.Tugas.Text = ""
  Me.UTS.Text = ""
  Me.UAS.Text = ""
  Me.Rata.Text = ""
  Me.Grade.Text = ""
  Nim.Enabled = True
Nama.Enabled = True
Tugas.Enabled = True
UTS.Enabled = True
UAS.Enabled = True
Rata.Enabled = False
Grade.Enabled = False
Command4.Visible = True
Command1.Visible = False
  Nim.SetFocus
End Sub
Private Sub Command2_Click()
If MsgBox("Yakin Ingin Menghapu Data..??", vbQuestion + vbOKCancel, "konfirmasi") = vbOK Then
Adodc1.Recordset.Delete
Me.DataGrid1.Refresh
End If
End Sub
Private Sub Command3_Click()
Dim sNPM As String
  sNPM = InputBox("Nama:")
 
  Adodc1.Recordset.MoveFirst
  Adodc1.Recordset.Find "Nama='" & sNPM & "'"
End Sub

Private Sub Command4_Click()
Adodc1.Recordset.Fields("Nim") = Me.Nim.Text
  Adodc1.Recordset.Fields("Nama") = Me.Nama.Text
  Adodc1.Recordset.Fields("Tugas") = Me.Tugas.Text
  Adodc1.Recordset.Fields("UTS") = Me.UTS.Text
  Adodc1.Recordset.Fields("UAS") = Me.UAS.Text
  Adodc1.Recordset.Fields("Rata") = Me.Rata.Text
  Adodc1.Recordset.Fields("Grade") = Me.Grade.Text
  Command4.Visible = False
Command1.Visible = True
  MsgBox "Data Berhasil Disimpan..!!", vbOKOnly + vbInformation, "Konfirmasi"
  Me.DataGrid1.Refresh
End Sub

Private Sub Nama_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Tugas.SetFocus
End If
End Sub

Private Sub Nim_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Nama.SetFocus
End If
End Sub

Private Sub Tugas_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
UTS.SetFocus
End If
End Sub

Private Sub UAS_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then


    Rata = 20 / 100 * Val(Tugas) + 20 / 100 * Val(UTS) + 60 / 100 * Val(UAS)
        If Rata >= 86 And Rata <= 100 Then Grade = "A"
        If Rata >= 76 And Rata <= 85 Then Grade = "AB"
        If Rata >= 70 And Rata <= 75 Then Grade = "B"
        If Rata >= 60 And Rata <= 69 Then Grade = "BC"
        If Rata >= 56 And Rata <= 59 Then Grade = "C"
        If Rata >= 46 And Rata <= 55 Then Grade = "D"
        If Rata = 0 And Rata <= 45 Then Grade = "E"
End If
End Sub

Private Sub UTS_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
UAS.SetFocus
End If
End Sub

---------------------------------------------Coding Module database-------------------------------------------

Public Conn As New ADODB.Connection

Public Sub koneksi()
On Error GoTo konekErr

If Conn.State = 1 Then Conn.Close
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\mahasiswa.mdb;Persist Security Info=False"
Exit Sub

konekErr:
    MsgBox "Gagal menghubungkan ke Database ! Kesalahan pada : " & Err.Description, vbCritical, "Peringatan"
End Sub

Download Database

Download Database

     

Tidak ada komentar:

Posting Komentar

English French German Spain Italian Dutch Russian Portuguese Japanese Korean Arabic Chinese Simplified
Antispam