Fungsi in_array di Visual Basic ( VB6 )


Public Function in_array(kata, kumpulanKata) As Boolean
    'untuk variabel kumpulanKata harus Anda perhatikan tanda separasinya
    'disini saya menggunakan koma
    Dim i As Integer, ret As Boolean
    Dim haystack() As String
    haystack() = Split(kumpulanKata, ",") 'tanda separasi
    ret = False 'set nilai boolean awal
    For i = LBound(haystack) To UBound(haystack)
        If haystack(i) = needle Then ret = True
        'jika ada kata yang ditemukan boolean akan bernilai true
    Next i
    in_array = ret
End Function

Private Sub Form_Load()
    Dim kumpulanKata as String
    Dim cariKata as String

    kumpulanKata = "rendra,kurniawan,ika,aku"
    cariKata = "ika"

    If in_array(cariKata, kumpulanKata) Then
         MsgBox "Yaph kata ditemukan"
    Else
         MsgBox "Maaf, kata yang Anda cari tidak ada"
    End If
End Sub

One thought on “Fungsi in_array di Visual Basic ( VB6 )

  1. saya mahasiswa ti nr smtr 7 saya bingung mau buat apa tugas akhir utk info sy baru belajar vb 2005 mysql , tolong sy dengan apa aja dong, sintak juga boleh atau apa aja emai saya aby_rosy@yahoo.com ya allah ilhami saya dngan hamba yang mau bantu saya ………..

Mari Berdiskusi Bersama

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s