Skip to content

Instantly share code, notes, and snippets.

@canokay
Last active November 15, 2018 08:33
Show Gist options
  • Save canokay/88d6714aa7f60ec16da5d792e689e3a0 to your computer and use it in GitHub Desktop.
Save canokay/88d6714aa7f60ec16da5d792e689e3a0 to your computer and use it in GitHub Desktop.
Visual Basic Array Functions Example
Public Class Form1
Private Sub btnUboundResult1_Click(sender As Object, e As EventArgs) Handles btnUboundResult1.Click
Dim dizi(4) As String
MessageBox.Show(UBound(dizi))
End Sub
Private Sub btnUboundResult2_Click(sender As Object, e As EventArgs) Handles btnUboundResult2.Click
Dim dizi(4, 6) As String
MessageBox.Show(UBound(dizi, 2))
End Sub
Private Sub btnLengthResult1_Click(sender As Object, e As EventArgs) Handles btnLengthResult1.Click
Dim dizi(1, 4, 4, 5, 6) As String
MessageBox.Show(dizi.Length())
End Sub
Private Sub btnGetLengthResult1_Click(sender As Object, e As EventArgs) Handles btnGetLengthResult1.Click
Dim dizi(10, 40, 50, 80, 90) As String
MessageBox.Show(dizi.GetLength(4))
End Sub
Private Sub btnRankResult1_Click(sender As Object, e As EventArgs) Handles btnRankResult1.Click
Dim dizi(1, 4, 4, 5, 6) As String
MessageBox.Show(dizi.Rank)
End Sub
Private Sub btnReverseResult1_Click(sender As Object, e As EventArgs) Handles btnReverseResult1.Click
Dim harfler() As String = {"A", "B", "C"}
Array.Reverse(harfler)
MsgBox(harfler(2))
'Sonuc = A
End Sub
Private Sub btnReverseResult2_Click(sender As Object, e As EventArgs) Handles btnReverseResult2.Click
Dim harfler() As String = {"A", "B", "C"}
Array.Reverse(harfler, 0, 1)
MsgBox(harfler(2))
'Sonuc = C
End Sub
Private Sub btnIndexOfResult1_Click(sender As Object, e As EventArgs) Handles btnIndexOfResult1.Click
Dim notlar() As Single = {78.1, 99.9, 100, 12.2}
Dim maxNot As Single = 100
MsgBox(Array.IndexOf(notlar, maxNot))
'Aranan maxNot degeri indisi = 2
End Sub
End Class

Dizilerde Metotlar

UBound()

Dizinin en son elemani veya eleman sayisindan bir fazlasını ogrenmek icin kullanilan bir fonksiyondur.

Length()

Dizinin bütün boyutlarindaki toplam eleman sayisini veren ozelliktir.

GetLength()

Indisi verilen boyutun kac elemanli oldugunu gosterir. Burada indis 0 dan baslar.

.Rank

Dizi boyutunu gösterir.

Reverse()

Diziyi ters cevirir.

IndexOf()

Ilk paremetrede verilen dizide, ikinci parametrede verilen degeri arar. Aranan deger dizide bulnursa insiai, bulunmazsa -1 doner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment