berikut adalah Listing Program Array :
Public Class frmArray
Private Sub btnElemen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnElemen.Click
LBoxHasil.Items.Clear()
Dim strFriend(4) As String
strFriend(0) = "Wendy"
strFriend(1) = "Harriet"
strFriend(2) = "Jay"
strFriend(3) = "Michelle"
strFriend(4) = "Richard"
LBoxHasil.Items.Add(strFriend(0))
End Sub
Private Sub btnEnumerasi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnumerasi.Click
LBoxHasil.Items.Clear()
Dim strFriend(4) As String
strFriend(0) = "Wendy"
strFriend(1) = "Harriet"
strFriend(2) = "Jay"
strFriend(3) = "Michelle"
strFriend(4) = "Richard"
For Each strName As String In strFriend
LBoxHasil.Items.Add(strName)
Next
End Sub
Private Sub btnSorting_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSorting.Click
LBoxHasil.Items.Clear()
Dim strFriend(4) As String
strFriend(0) = "Wendy"
strFriend(1) = "Harriet"
strFriend(2) = "Jay"
strFriend(3) = "Michelle"
strFriend(4) = "Richard"
Array.Sort(strFriend)
For Each strName As String In strFriend
LBoxHasil.Items.Add(strName)
Next
End Sub
Private Sub btnReverse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReverse.Click
LBoxHasil.Items.Clear()
Dim strFriend(4) As String
strFriend(0) = "Wendy"
strFriend(1) = "Harriet"
strFriend(2) = "Jay"
strFriend(3) = "Michelle"
strFriend(4) = "Richard"
Array.Reverse(strFriend)
For Each strName As String In strFriend
LBoxHasil.Items.Add(strName)
Next
End Sub
Private Sub btnNilaiAwal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNilaiAwal.Click
LBoxHasil.Items.Clear()
Dim strFriend() As String = {"Eliane", "Richard", "Wendy", "Harriest", "Debra"}
For Each strName As String In strFriend
LBoxHasil.Items.Add(strName)
Next
End Sub
Private Sub btnKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnKeluar.Click
Me.Close()
End Sub
Private Sub btnLatihanArray_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLatihanArray.Click
LBoxHasil.Items.Clear()
LBoxHasil.Items.Add(" ")
LBoxHasil.Items.Add("Array Asal")
Dim Buah(4) As String
Buah(0) = "Mangga"
Buah(1) = "Pisang"
Buah(2) = "Jambu"
Buah(3) = "Apel"
Buah(4) = "Durian"
For Each strName As String In Buah
LBoxHasil.Items.Add(strName)
Next
LBoxHasil.Items.Add(" ")
LBoxHasil.Items.Add("Array Sort Ascending")
Dim Buah1(4) As String
Buah1(0) = "Mangga"
Buah1(1) = "Pisang"
Buah1(2) = "Jambu"
Buah1(3) = "Apel"
Buah1(4) = "Durian"
Array.Sort(Buah1)
For Each strName As String In Buah1
LBoxHasil.Items.Add(strName)
Next
LBoxHasil.Items.Add(" ")
LBoxHasil.Items.Add("Array Sort Descending")
Dim Buah2(4) As String
Buah2(0) = "Mangga"
Buah2(1) = "Pisang"
Buah2(2) = "Jambu"
Buah2(3) = "Apel"
Buah2(4) = "Durian"
Array.Reverse(Buah2)
For Each strName As String In Buah2
LBoxHasil.Items.Add(strName)
Next
End Sub
End Class
dari Codingan diatas menghasilkan Output:
Tidak ada komentar:
Posting Komentar