Setelah itu Double Click pada Command_Button "Hitung Rata-rata", Lalu Ketikan Koding dibawah ini :
Private Sub Command1_Click()
Jumlah = Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text) + Val(Text4.Text) + Val(Text5.Text)
Rata = Jumlah / 5
MsgBox ("Jumlah " & Jumlah)
MsgBox ("Nilai Rata-Ratanya Adalah : " & Rata)
Bersih
End Sub
Sub Bersih()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
End Sub
Private Sub Form_Load()
Dim Rata As Double
Dim Jumlah As Integer
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Not (KeyAscii >= Asc("0") & Chr(13) _
And KeyAscii <= Asc("9") & Chr(13) _
Or KeyAscii = vbKeyBack _
Or KeyAscii = vbKeyDelete _
Or KeyAscii = vbKeySpace) Then
Beep
KeyAscii = 0
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If Not (KeyAscii >= Asc("0") & Chr(13) _
And KeyAscii <= Asc("9") & Chr(13) _
Or KeyAscii = vbKeyBack _
Or KeyAscii = vbKeyDelete _
Or KeyAscii = vbKeySpace) Then
Beep
KeyAscii = 0
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If Not (KeyAscii >= Asc("0") & Chr(13) _
And KeyAscii <= Asc("9") & Chr(13) _
Or KeyAscii = vbKeyBack _
Or KeyAscii = vbKeyDelete _
Or KeyAscii = vbKeySpace) Then
Beep
KeyAscii = 0
End If
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
If Not (KeyAscii >= Asc("0") & Chr(13) _
And KeyAscii <= Asc("9") & Chr(13) _
Or KeyAscii = vbKeyBack _
Or KeyAscii = vbKeyDelete _
Or KeyAscii = vbKeySpace) Then
Beep
KeyAscii = 0
End If
End Sub
Private Sub Text5_KeyPress(KeyAscii As Integer)
If Not (KeyAscii >= Asc("0") & Chr(13) _
And KeyAscii <= Asc("9") & Chr(13) _
Or KeyAscii = vbKeyBack _
Or KeyAscii = vbKeyDelete _
Or KeyAscii = vbKeySpace) Then
Beep
KeyAscii = 0
End If
End Sub
Dan ini hasir setelah di RUN
1 Comments
waaawwww keren,,, tp g ngrtii emmm hahaha tp goog artikelnya
ReplyDeleteisi komentar anda di sini