Senin, 08 Maret 2010

CONTOH PROGRAM SEDERHANA VISUAL BASIC

PENGHITUNGAN NILAI UAN SMA IPA







Ukuran huruf

PENJELASAN


Program ini adalah salah satu contoh program sederhana yang dapat dibuat di Visual Basic. Program ini tentang cara penghitungan nilai rata-rata dan penentuan kelulusan siswa IPA.



SOURCE CODE


Public Class Form1

Private Sub mulai_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mulai.Click
nis.Text = " "
nama.Text = " "
mtk.Text = " "
bahasa.Text = " "
inggris.Text = " "
biologi.Text = " "
fisika.Text = " "
kimia.Text = " "
total.Text = " "
rata.Text = " "
predikat.Text = " "
status.Text = " "
End Sub

Private Sub selesai_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles selesai.Click
Dim x As Integer
x = MsgBox("DO YOU WANT TO QUIT?", MsgBoxStyle.OkCancel + MsgBoxStyle.Question, "WARNING")
If x = vbOK Then
End
End If
End Sub

Private Sub hitung_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hitung.Click

total.Text = Val(mtk.Text) + Val(bahasa.Text) + Val(inggris.Text) + Val(biologi.Text) + Val(fisika.Text) + Val(kimia.Text)

rata.Text = total.Text / 6

Select Case rata.Text()
Case Is = 100
predikat.Text = "A"
Case Is >= 85
predikat.Text = "A"
Case Is >= 75
predikat.Text = "B"
Case Is >= 65
predikat.Text = "C"
Case Is >= 55
predikat.Text = "D"
Case Else
predikat.Text = "E"
End Select

If rata.Text >= 65 Then
status.Text = "LULUS"
Else
status.Text = "TIDAK LULUS"
End If
End Sub
End Class