Public Class Form1
Inherits System.Windows.Forms.Form
Private myArray() As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Put some test data in our array
Dim temp As String
temp = "cat,dog,elephant,cougar,crab,bear,fish,camel"
myArray = Split(temp, ",")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim match As String
Dim matches As ArrayList = getEntries("c")
For Each match In matches
' do something with each match
Debug.WriteLine(match)
Next
End Sub
Private Function getEntries(ByVal beginningWith As String) As ArrayList
Dim entries As ArrayList = New ArrayList
Dim i As Integer
For i = 0 To myArray.GetUpperBound(0)
If myArray(i).StartsWith(beginningWith) Then
entries.Add(myArray(i))
End If
Next i
Public Class Form1
Inherits System.Windows.Forms.Form
Private myArray() As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Put some test data in our array
Dim temp As String
temp = "cat,dog,elephant,cougar,c
myArray = Split(temp, ",")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim match As String
Dim matches As ArrayList = getEntries("c")
For Each match In matches
' do something with each match
Debug.WriteLine(match)
Next
End Sub
Private Function getEntries(ByVal beginningWith As String) As ArrayList
Dim entries As ArrayList = New ArrayList
Dim i As Integer
For i = 0 To myArray.GetUpperBound(0)
If myArray(i).StartsWith(begi
entries.Add(myArray(i))
End If
Next i
Return entries
End Function
End Class