Tutorial Vb.Net : Penggunaan Arrays di Vb.Net Lengkap

Tutorial Belajar Vb.Net pemula : Cara Penggunaan Arrays di Vb.Net,Dynamic Arrays,Multi-Dimensional Arrays, Jagged Array, dan class array Lengkap. tutorial vb.net di sector code

Arrays Vb.Net - Belajar vb.net pemula pada tutorial ini tentang Arrays, bagaimana cara mendeklarasikan array, memanipulasi data dalam array dan macam - macam array dalam vb.net akan dibahas nanti ya. sebelumnya kami juga sudah membahas tutorial array dalam bahasa pemrograman java, silahkan baca Tutorial Java : Array dan Array Multidimensi Dalam Java.

Membuat array di vb.net

Tutorial Vb.Net : Penggunaan Arrays di Vb.Net Lengkap
untuk mendeklarasikan sebuah array di vb.net silahkan ligat contoh berikut :
Module Module1

    Sub Main()
        Dim Array1(10) ' array ini akan memiliki element sebanyak 11
        Dim Array2(15) As String 'Array yang memiliki16 element string
        Dim Array3(10, 20) As Integer 'Array 2 dimensi
        Dim Array4(10, 100) 'Array 2 dimensi
    End Sub

End Module

Contoh penggunaan Array dalam aplikasi console

Module Module1

    Sub Main()
        Dim Array1() As Integer = {12, 16, 20, 24, 28,
            32} ' array ini akan memiliki element sebanyak 11
        Dim Array2() As String = {"Harison", "Sector Code", "Ganteng",
            "Banget"} 'Array yang memiliki16 element string
    End Sub

End Module
Module Module1

    Sub Main()
        Dim x(10) As Integer  ' n is an array of 11 integers '
        Dim y, z As Integer
        ' initialize elements of array n '         
        For y = 0 To 10
            x(y) = y + 100 ' set element at location i to i + 100 
        Next y
        ' output each array element's value '
        For z = 0 To 10
            Console.WriteLine("Element({0}) = {1}", z, x(z))
        Next z
        Console.ReadKey()
    End Sub

End Module
Untuk referensi silahkan lita tutorial berikut http://www.tutorialspoint.com/vb.net/vb.net_arrays.htm
dan dalam aplikasi console diatas akan menghasilkan pesan :
Element(0) = 100
Element(1) = 101
Element(2) = 102
Element(3) = 103
Element(4) = 104
Element(5) = 105
Element(6) = 106
Element(7) = 107
Element(8) = 108
Element(9) = 109
Element(10) = 110

Declare Dynamic Arrays Vb.NET

Mendeklarasikan Arrays Dynamic vb.net bisa dengan menggunakan pernyataan ReDim. lihat contoh sytax ReDim berikut:
ReDim [Preserve] arrayname(subscripts)
Module Module1

    Sub Main()
        Dim SC() As Integer
        ReDim SC(2)
        SC(0) = 85
        SC(1) = 75
        SC(2) = 90
        ReDim Preserve SC(10)
        SC(3) = 80
        SC(4) = 76
        SC(5) = 92
        SC(6) = 99
        SC(7) = 79
        SC(8) = 75
        For i = 0 To 10
            Console.WriteLine(i & vbTab & SC(i))
        Next i
        Console.ReadKey()
    End Sub

End Module
Aplikasi diatas akan menghasilkan pesan :
0       85
1       75
2       90
3       80
4       76
5       92
6       99
7       79
8       75
9       0
10      0

Multi-Dimensional Arrays

Berikut penggunaan Multi-Dimensional Arrays dalam vb.net
Module Module1

    Sub Main()
        ' an array with 5 rows and 2 columns
        Dim a(,) As Integer = {{0, 0}, {1, 2}, {2, 4}, {3, 6}, {4, 8}}
        Dim i, j As Integer
        ' output each array element's value '
        For i = 0 To 4
            For j = 0 To 1
                Console.WriteLine("a[{0},{1}] = {2}", i, j, a(i, j))
            Next j
        Next i
        Console.ReadKey()
    End Sub

End Module
Maka akan menghasilkan pesan :
a[0,0] = 0
a[0,1] = 0
a[1,0] = 1
a[1,1] = 2
a[2,0] = 2
a[2,1] = 4
a[3,0] = 3
a[3,1] = 6
a[4,0] = 4
a[4,1] = 8

Jagged Array dalam Vb.Net

Syntaxnya :
Dim scores As Integer()() = New Integer(5)(){}
Module Module1

    Sub Main()
        'a jagged array of 5 array of integers
        Dim x As Integer()() = New Integer(4)() {}
        x(0) = New Integer() {0, 0}
        x(1) = New Integer() {1, 2}
        x(2) = New Integer() {2, 4}
        x(3) = New Integer() {3, 6}
        x(4) = New Integer() {4, 8}
        Dim y, z As Integer
        ' output each array element's value 
        For y = 0 To 4
            For z = 0 To 1
                Console.WriteLine("a[{0},{1}] = {2}", y, z, x(y)(z))
            Next z
        Next y
        Console.ReadKey()
    End Sub

End Module
Maka akan menghasilkan pesan
a[0,0] = 0
a[0,1] = 0
a[1,0] = 1
a[1,1] = 2
a[2,0] = 2
a[2,1] = 4
a[3,0] = 3
a[3,1] = 6
a[4,0] = 4
a[4,1] = 8
Buat referensi : http://www.tutorialspoint.com/vb.net/vb.net_arrays.htm

Jangan sungkan-sungkan untuk bertanya pada kotak komentar dibawah ini ya. terima kasih :)

COMMENTS


Feel free to code it up and send us a pull request.

Hi everyone, let's me know how much this lesson can help your work. Please Subscribe and Follow Our Social Media 'kodeajaib[dot]com' to get Latest tutorials and will be send to your email everyday for free!, Just hit a comment if you have confused. Nice to meet you and Happy coding :) all ^^



Follow by E-Mail


Name

ADO.NET,3,Ajax,6,Android,9,AngularJS,4,ASP.NET,4,Blogger Tutorials,7,Bootstrap,7,C++,1,Codeigniter,2,Cplusplus,6,Crystal Report,6,CSharp,25,Ebook Java,2,FlyExam,1,FSharp,3,Game Development,2,Java,35,JDBC,2,Laravel,89,Lumen,2,MariaDB,2,Ms Access,3,MySQL,31,ODBC,6,OleDB,1,PHP,14,PHP Framework,6,PHP MYSQLI,9,PHP OOP,5,Python,8,Python 3,4,SQL Server,4,SQLite,4,Uncategorized,5,Vb 6,2,Vb.Net,89,Video,48,Vue Js,4,WPF,2,Yii,3,
ltr
item
KODE AJAIB: Tutorial Vb.Net : Penggunaan Arrays di Vb.Net Lengkap
Tutorial Vb.Net : Penggunaan Arrays di Vb.Net Lengkap
Tutorial Belajar Vb.Net pemula : Cara Penggunaan Arrays di Vb.Net,Dynamic Arrays,Multi-Dimensional Arrays, Jagged Array, dan class array Lengkap. tutorial vb.net di sector code
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDsVkddjP0sCfc0us-Lx6Ngj9MByQFBsabV8wrQ88Pa9WDGY4QpqsDTYbVq1Ozn4vPVtZHfU9jNZQtel3Glp-BKwg9ObzTqXAb22dh8BeUs1Sxy-Pg_zbFjxKBijMelI1eFQ6qekqu8e4/s320/array-dalam-vbnet.jpg
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDsVkddjP0sCfc0us-Lx6Ngj9MByQFBsabV8wrQ88Pa9WDGY4QpqsDTYbVq1Ozn4vPVtZHfU9jNZQtel3Glp-BKwg9ObzTqXAb22dh8BeUs1Sxy-Pg_zbFjxKBijMelI1eFQ6qekqu8e4/s72-c/array-dalam-vbnet.jpg
KODE AJAIB
https://scqq.blogspot.com/2015/11/tutorial-vbnet-penggunaan-arrays-vbnet.html
https://scqq.blogspot.com/
https://scqq.blogspot.com/
https://scqq.blogspot.com/2015/11/tutorial-vbnet-penggunaan-arrays-vbnet.html
true
3214704946184383982
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy