Latihan Visual Basic
       2010
    Disusun oleh:
    Nurul Arhaiyyu
     1113000003
       Jurusan:
   Sistem Informasi

Asian Banking Finance
And Informatics Institute
   ABFI INSTITUTE
      PERBANAS
PROGRAM PANGKAT
Source Code:
    Private Sub Button2_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
        TextBox1.Clear()
        TextBox2.Clear()
        TextBox3.Clear()
        TextBox1.Focus()
    End Sub
    Private Sub Button3_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles Button3.Click
        Close()
    End Sub
    Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
        Dim nilai As Integer
        Dim pangkat As Integer
        Dim i As Integer
        Dim jumlah As Integer
        nilai = Val(TextBox1.Text)
        pangkat = Val(TextBox2.Text)
        jumlah = 1
        For i = 1 To pangkat
            jumlah = jumlah * nilai
        Next
        TextBox3.Text = jumlah
    End Sub
    Private Sub Button4_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles Button4.Click
        Form1.Show()
    End Sub
End Class
PROGRAM PERULANGAN PENJ
PENJELASAN:


AWAL: 1
AKHIR: 5

HASIL: 15

Nilai awal+Nilai akhir tetapi secara
perulangan
Artinya 1+2+3+4+5 = 15
Source Code:
     Private Sub Button3_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles Button3.Click
          Close()
     End Sub
     Private Sub Button2_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
          TextBox1.Clear()
          TextBox2.Clear()
          TextBox3.Clear()
          TextBox1.Focus()
     End Sub
     Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
          Dim jumlah As Integer
          Dim awal As Integer
          Dim akhir As Integer
          Dim i As Integer
          awal = Val(TextBox1.Text)
          akhir = Val(TextBox2.Text)
          For i = awal To akhir
              jumlah = jumlah + i
          Next
          TextBox3.Text = jumlah
     End Sub
     Private Sub Button4_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles Button4.Click
          Form2.Show()
     End Sub
End Class

Latihan visual basic 2010/Looping/Perulangan

  • 1.
    Latihan Visual Basic 2010 Disusun oleh: Nurul Arhaiyyu 1113000003 Jurusan: Sistem Informasi Asian Banking Finance And Informatics Institute ABFI INSTITUTE PERBANAS
  • 2.
  • 3.
    Source Code: Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Clear() TextBox2.Clear() TextBox3.Clear() TextBox1.Focus() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Close() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim nilai As Integer Dim pangkat As Integer Dim i As Integer Dim jumlah As Integer nilai = Val(TextBox1.Text) pangkat = Val(TextBox2.Text) jumlah = 1 For i = 1 To pangkat jumlah = jumlah * nilai Next TextBox3.Text = jumlah End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Form1.Show() End Sub End Class
  • 4.
  • 5.
    PENJELASAN: AWAL: 1 AKHIR: 5 HASIL:15 Nilai awal+Nilai akhir tetapi secara perulangan Artinya 1+2+3+4+5 = 15
  • 6.
    Source Code: Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Close() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Clear() TextBox2.Clear() TextBox3.Clear() TextBox1.Focus() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim jumlah As Integer Dim awal As Integer Dim akhir As Integer Dim i As Integer awal = Val(TextBox1.Text) akhir = Val(TextBox2.Text) For i = awal To akhir jumlah = jumlah + i Next TextBox3.Text = jumlah End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Form2.Show() End Sub End Class