Aplikasi Perulangan/Looping Visual Basic 2010

Aplikasi Perulangan
  •  Form Design
 
 
  • Code 
 Public Class Latihan_9
    Dim mulai, akhir As Integer
    Sub hasil()
        Dim ulang As Integer
        mulai = Val(Me.txtMulai.Text)
        akhir = Val(Me.txtAkhir.Text)

        If mulai > akhir Then
            For ulang = mulai To akhir Step -1
                Me.lsHasil.Items.Add(ulang)
            Next
        Else
            For ulang = mulai To akhir
                Me.lsHasil.Items.Add(ulang)
            Next
        End If

    End Sub

    Private Sub bBaru_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bBaru.Click
        Me.lsHasil.Items.Clear()
        Me.txtMulai.Text = ""
        Me.txtAkhir.Text = ""
        Me.txtMulai.Focus()
    End Sub

    Private Sub bProses_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bProses.Click
        Me.lsHasil.Items.Clear()
        Call hasil()

    End Sub

  Private Sub lat_9_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

End Class

  • Start Debugging

 
Artikel Selanjutnya Artikel Sebelumnya
Belum Ada Komentar :
Tambahkan Komentar
Comment url