Selasa, 26 Januari 2010

Menghitung Nilai ( Visual Basic )



Berikut Logika pembuatannya :

Private Sub Command1_Click()
Dim tugas, quis, uts, uas As Integer
tugas = Text1.Text
quis = Text2.Text
uts = Text3.Text
uas = Text4.Text
akhir = (tugas * 0.2) + (quis * 0.2) + (uts * 0.3) + (uas * 0.3)
Text5.Text = akhir

If akhir >= 90 Then
Text6.Text = "Nilai A"
ElseIf akhir >= 75 And akhir <= 89 Then Text6.Text = "Nilai B" ElseIf akhir >= 60 And akhir <= 74 Then Text6.Text = "Nilai C" ElseIf akhir >= 50 And akhir <= 59 Then Text6.Text = "Nilai D" Else Text6.Text = "ERROR" End If End Sub Private Sub Command2_Click() 'untuk membersihkan textox Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = "" Text5.Text = "" Text6.Text = "" Text1.SetFocus End Sub Private Sub Command3_Click() End End Sub Private Sub Form_Load() End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) 'fungsi enter \ pada saat dienter maka akan fokus ke text2 If KeyAscii = 13 Then Text2.SetFocus End If End Sub Private Sub Text2_KeyPress(KeyAscii As Integer) 'fungsi enter \ pada saat dienter maka akan fokus ke text2 If KeyAscii = 13 Then Text3.SetFocus End If End Sub Private Sub Text3_KeyPress(KeyAscii As Integer) 'fungsi enter \ pada saat dienter maka akan fokus ke text2 If KeyAscii = 13 Then Text4.SetFocus End If End Sub Private Sub Text5_KeyPress(KeyAscii As Integer) 'fungsi enter \ pada saat dienter maka akan fokus ke text2 If KeyAscii = 13 Then Text5.SetFocus End If End Sub Private Sub Text6_KeyPress(KeyAscii As Integer) 'fungsi enter \ pada saat dienter maka akan fokus ke text2 If KeyAscii = 13 Then Text5.SetFocus End If End Sub

Tidak ada komentar:

Posting Komentar