MENENTUKAN JUMLAH NILAI DAN RATA-RATA
ASSALAMU'ALAIKUM WARAHMATULLAHI WABAROKATUH :)
SELAMAT DATANG DI BLOG SAYA, SAYA AKAN MEMPOSTING
MENGENAI PROGRAM VISUAL BASIC 10 YANG
SAYA BUAT
PROJECT LATIHAN11
BERIKUT ADALAH CODING MENENTUKAN JUMLAH NILAI DAN RATA-RATA
Public Class Formlatihan11
Dim jumlah, rerata As
Integer
Dim data As String
Private Sub
BInput_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
BInput.Click
Dim ulang, inputdata As
Integer
If Val(Me.Txtbanyakdata.Text)
>= 1 Then
'Lanjutkan proses
ulang =
1
While (ulang <= Val(Me.Txtbanyakdata.Text))
inputdata = Val(InputBox("Masukan data
ke" & ulang & ":"))
jumlah = jumlah + inputdata
data = data & " " &
inputdata
ulang = ulang + 1
End While
rerata
= jumlah / Val(Me.Txtbanyakdata.Text)
Me.TxtData.Text = data.ToString
Me.TxtJumlah.Text = jumlah.ToString
Me.Txtratarata.Text = rerata.ToString
Else
'Inputkan banyak data
Me.Txtbanyakdata.Text = ""
Me.Txtbanyakdata.Focus()
End If
End Sub
Private Sub Formlatihan11_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs)
Handles Me.FormClosed
utama.Enabled = True
utama.Show()
Me.Hide()
End Sub
Private Sub
Formlatihan11_FormClosing(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
utama.Enabled = True
utama.Show()
Me.Hide()
End Sub
End Class
Tidak ada komentar:
Posting Komentar