Public Class Private Sub Byval As Byval As Handles Mybase: Form1 Object Eventargs

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MyBase.Load
Label1.Text = "Jumlah Bilangan"
Button1.Text = "Proses"
Label2.Text = "Daftar Bilangan"
Label3.Text = "Jumlah"
Label4.Text = "Rata-rata"
Label5.Text = "Terbesar"
Label6.Text = "Terkecil"
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
If TextBox1.Text = "" Then
MessageBox.Show("Tidak boleh kosong", "Peringatan", MessageBoxButtons.OK,
MessageBoxIcon.Information)
End If

Dim rerata As Integer


Dim sum As Integer
Dim i As Integer
Dim x As Integer

ListBox1.Items.Clear()
x = Val(TextBox1.Text)
sum = 0
For i = 1 To x
ListBox1.Items.Add(i)
sum = sum + i
Next

rerata = sum / x

TextBox4.Text = x
TextBox5.Text = 1
TextBox2.Text = sum
TextBox3.Text = rerata

End Sub
End Class

You might also like