Kamis, 25 Desember 2014

[Tugas Pemograman Visual] Belajar Looping Piramida Pada VB.Net

Hai guys, malam-malam seperti ini seru juga untuk belajar (memang tugas lagi banyak sih hehe). Kali ini saya akan memosting tentang looping piramida. Yes, perulangan pada VB.net. Langsung aja lihat designnya di bawah ini.

Lalu silakan ikuti coding yang ada di bawah ini:

Public Class Form1

    Private Sub Proses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Proses.Click
        Dim x, y, z As Integer
        x = 1 : y = NumericUpDown1.Value
        TextBox1.Clear()
        Do While x <= y
            z = 1
            TextBox1.Text = _
            TextBox1.Text & Space(y - x)
            Do While z <= x
                TextBox1.Text = _
                TextBox1.Text & " " & z
                z += 1
            Loop
            TextBox1.Text = _
            TextBox1.Text & vbCrLf
            x += 1
        Loop

    End Sub

    Private Sub keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles keluar.Click
        Me.Close()
    End Sub
End Class


Maka, hasilnya akan seperti ini:



Semoga bermanfaat guys.





Subscribe to Our Blog Updates!




Share this article!

Tidak ada komentar:

Posting Komentar

Return to top of page
Powered By Blogger | Design by Genesis Awesome | Blogger Template by Lord HTML