Log in

View Full Version : Ask Pengolahan Nilai (cendol inside)


Permenkaret
20th November 2011, 02:22 AM
CASE CLOSED!!!!!

Makasih buat agan elfapega


Quote:






Originally Posted by elfapega
http://static.kaskus.us/images/buttons/viewpost.gif (http://ceriwis.us/showthread.php?p=306073697#post306073697)


misal nama textnya adalah :

txtPK, txtMID, txtUAS, txtNT



dengan asumsi, bahwa semua text sudah terhubung ke adodc-nya (datasource & datafield)



buat sub tambahan sbb :


Code:

Private Sub hitung()
txtNT.Text = (3 * Val(txtPK.Text) + 2 * Val(txtMID.Text) + Val(txtUAS.Text)) / 6
End Sub

nanti di txtPK, txtMID, txtUAS - change


Code:

Private Sub txtMID_Change()
Call hitung
End Sub

Private Sub txtPK_Change()
Call hitung
End Sub

Private Sub txtUAS_Change()
Call hitung
End Sub










Agan-agan jago programing,,,mau minta tolong script...

ane punya form untuk pengolahan nilai gan,,,

ini wujudnya gan...

http://u.kaskus.us/39/jpktjnb3.jpg



ini source codenya gan


Code:

Option Explicit

Public pTransJns As String
Public pTransID As String
Dim rstSiswa As ADODB.Recordset
Dim rstMatPel As ADODB.Recordset
Dim rstTrans As ADODB.Recordset
Private Sub loadSiswa()
Set rstSiswa = New ADODB.Recordset
If rstSiswa.State = adStateOpen Then rstSiswa.Close
gstrSQL = "Select idsiswa, nis, nama, jeniskelamin, tempatlahir, tanggallahir, agama,namaortu From siswa"
Set rstSiswa = Cn.Execute(gstrSQL)
Set dcbSiswa.RowSource = rstSiswa

dcbSiswa.ListField = "nama"
dcbSiswa.DataField = "nis"
dcbSiswa.BoundColumn = "nis"

dcbSiswa.BoundText = vbNullString
End Sub
Private Sub loadMatPel()
Set rstMatPel = New ADODB.Recordset
If rstMatPel.State = adStateOpen Then rstMatPel.Close
gstrSQL = "Select kode_mapel, mapel From matpel"
Set rstMatPel = Cn.Execute(gstrSQL)
Set dcbMatPel.RowSource = rstMatPel

dcbMatPel.ListField = "mapel"
dcbMatPel.DataField = "kode_mapel"
dcbMatPel.BoundColumn = "kode_mapel"

dcbMatPel.BoundText = vbNullString
End Sub

Private Sub loadTrans()
Set rstTrans = New ADODB.Recordset
If rstTrans.State = adStateOpen Then rstTrans.Close
gstrSQL = "Select A.id, A.ta, A.smst, A.nis, A.kode_mapel, A.kkm, A.pk, A.mid, A.uas, A.nilai_praktik " & vbCrLf _
& "From gurumatpel A " & vbCrLf _
& "Left Outer Join siswa B On B.nis = A.nis " & vbCrLf _
& "Where id = '" & pTransID & "'"
Set rstTrans = Cn.Execute(gstrSQL)
If Not (rstTrans.BOF And rstTrans.EOF) Then
txtID.Text = rstTrans![Id]
If IsNull(rstTrans![nis]) Then
dcbSiswa.BoundText = vbNullString
Else
dcbSiswa.BoundText = rstTrans![nis]
End If
If IsNull(rstTrans![ta]) Then
Text2.Text = vbNullString
Else
Text2.Text = rstTrans![ta]
End If
If IsNull(rstTrans![smst]) Then
Combo1.Text = vbNullString
Else
Combo1.Text = rstTrans![smst]
End If
If IsNull(rstTrans![kode_mapel]) Then
dcbMatPel.BoundText = vbNullString
Else
dcbMatPel.BoundText = rstTrans![kode_mapel]
End If
If IsNull(rstTrans![kkm]) Then
Text3.Text = vbNullString
Else
Text3.Text = rstTrans![kkm]
End If
If IsNull(rstTrans![pk]) Then
Text5.Text = vbNullString
Else
Text5.Text = rstTrans![pk]
End If
If IsNull(rstTrans![Mid]) Then
Text6.Text = vbNullString
Else
Text6.Text = rstTrans![Mid]
End If
If IsNull(rstTrans![uas]) Then
Text7.Text = vbNullString
Else
Text7.Text = rstTrans![uas]
End If
If IsNull(rstTrans![nilai_praktik]) Then
Text8.Text = vbNullString
Else
Text8.Text = rstTrans![nilai_praktik]
End If
Else
txtID.Text = vbNullString
dcbSiswa.BoundText = vbNullString
Text2.Text = vbNullString
Combo1.Text = vbNullString
dcbMatPel.BoundText = vbNullString
Text3.Text = vbNullString
Text5.Text = vbNullString
Text6.Text = vbNullString
Text7.Text = vbNullString
Text8.Text = vbNullString
End If

If UCase$(pTransJns) = "ADD" Then
txtID.Locked = False
Else
txtID.Locked = True
End If
End Sub

Private Sub clearComponent()
dcbSiswa.BoundText = vbNullString
Text2.Text = vbNullString
Combo1.Text = vbNullString
dcbMatPel.BoundText = vbNullString
Text3.Text = vbNullString
Text5.Text = vbNullString
Text6.Text = vbNullString
Text7.Text = vbNullString
Text8.Text = vbNullString

pTransID = vbNullString
End Sub

Private Sub btnClose_Click()
Unload Me
End Sub

'---------------------------------------------------------------------------------------
' Procedure : btnSave_Click
' Author : admin
' Date : 5/7/2010
' Purpose :
'---------------------------------------------------------------------------------------
'
Private Sub btnSave_Click()
On Error GoTo btnSave_Click_Error
If dcbSiswa.BoundText = vbNullString Then
MsgBox "Pilih SISWA"
dcbSiswa.SetFocus
Exit Sub
End If
If Text2.Text = vbNullString = vbNullString Then
MsgBox "Isikan TAHUN AJARAN"
Text2.SetFocus
Exit Sub
End If
If Combo1.Text = vbNullString = vbNullString Then
MsgBox "Pilih SEMESTER"
Combo1.SetFocus
Exit Sub
End If
If CdcbMatPel.BoundText = vbNullString = vbNullString Then
MsgBox "Pilih MATAPELAJARAN"
CdcbMatPel.SetFocus
Exit Sub
End If
If Text3.Text = vbNullString Then
MsgBox "Isikan Nilai KKM"
dcbMatPel.SetFocus
Exit Sub
End If
If Text5.Text = vbNullString Then
MsgBox "Isikan Penilaian Kelas"
Text5.SetFocus
Exit Sub
End If
If Text6.Text = vbNullString Then
MsgBox "Isikan Nilai MID"
Text6.SetFocus
Exit Sub
If Text7.Text = vbNullString Then
MsgBox "Isikan Nilai UAS"
Text7.SetFocus
Exit Sub
End If
If Text8.Text = vbNullString Then
MsgBox "Isikan Nilai PRAKTIK"
Text8.SetFocus
Exit Sub
End If
If UCase$(pTransJns) = "ADD" Then
gstrSQL = "Insert Into nilai_siswa (nis, ta, smst, kode_mapel, kkm, pk, mid, uas, nilai_praktik) Values ('" & dcbSiswa.BoundText & "','" & Text2.Text & "','" & Combo1.Text & "', '" & dcbMatPel.BoundText & "', '" & Text3.Text & "', '" & Text5.Text & "', '" & Text6.Text & "', '" & Text7.Text & "', '" & Text8.Text & "', )"
Cn.Execute (gstrSQL)
ElseIf UCase$(pTransJns) = "EDIT" Then
gstrSQL = "Update nilai_siswa Set nis = '" & dcbSiswa.BoundText & "', ta = '" & Text2.Text & "', smst = '" & Combo1.Text & "', kode_matpel = '" & dcbMatPel.BoundText & "', kkm = '" & Text3.Text & "', pk = '" & Text5.Text & "', mid = '" & Text6.Text & "', uas = '" & Text7.Text & "', nilai_praktik = '" & Text8.Text & "', Where id = '" & pTransID & "'"
Cn.Execute (gstrSQL)
End If

txtID.Locked = True
pTransJns = "EDIT"
frmView.LoadData

MsgBox "Sukses..."

On Error GoTo 0
Exit Sub

btnSave_Click_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure btnSave_Click of Form frmCreate"
End Sub
Private Sub Form_Load()
Combo1.AddItem "Ganjil"
Combo1.AddItem "Genap"
If UCase$(pTransJns) = "ADD" Then
Call loadSiswa
Call loadMatPel

Call clearComponent
ElseIf UCase$(pTransJns) = "EDIT" Then
Call loadSiswa
Call loadMatPel

Call loadTrans
End If
End Sub

Database nya gini gan,,

Nama DB = akademik

nama tabel = nilai_siswa

field nya gan = id, nis, ta, smst, kode_mapel, kkm, pk, mid, uas, nilai_tertulis, nilai_praktik



Inputnya di form itu,,,,,nis, ta, smst, kode_mapel, kkm, pk, mid, uas, nilai_praktik



Nanti waktu di data base,,,,nilai terrulisnya ngisi dengan rumus gini gan

nilau_tertulis=(3pk+2mid+UAS)/6,,,

ntuh gimana ya gan coddingnya??mohon pencerahan gan,,,

nanti yang bisa langsung ditimpuk :melonndan:

</div>