Public Class frmJuke
Dim strDahArray(0 To 2) As String
Dim arrTestMyList As New ArrayList
Dim hashTable As New Hashtable
Dim qQueue As New Queue
Private Sub btnAddCD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnArray.Click
strDahArray(0) = "This is cool"
strDahArray(1) = "This is cooler"
strDahArray(2) = "This is the coolest"
For x As Integer = 0 To 2
MsgBox(strDahArray(x))
Next
lstArray.DataSource = strDahArray
cboArray.DataSource = strDahArray
End Sub
Private Sub btnArrayList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnArrayList.Click
arrTestMyList.Add("this is not cool")
arrTestMyList.Add("not even this is cool")
arrTestMyList.Add("this sux")
For Each Str As String In arrTestMyList
MsgBox(Str)
Next
lstArray.DataSource = arrTestMyList
cboArray.DataSource = arrTestMyList
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
arrTestMyList.Clear()
For y As Integer = 0 To (strDahArray.Length - 1)
strDahArray(y) = ""
Next
lstArray.DataSource = Nothing
cboArray.DataSource = Nothing
End Sub
Private Sub btnAddToArrayList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddToArrayList.Click
arrTestMyList.Add(txtArrayList.Text)
txtArrayList.Clear()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
hashTable.Add("box1", "asdf")
hashTable.Add("box2", "jld;fkajdf;lasdf")
For Each obj As DictionaryEntry In hashTable
MsgBox(obj.Key & "=" & obj.Value)
Next
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim str As String
qQueue.Enqueue("third")
qQueue.Enqueue("second")
qQueue.Enqueue("first")
Do While qQueue.Count > 0
str = qQueue.Dequeue()
MsgBox(str)
Loop
End Sub
End Class
Friday, March 4, 2011
Array examples
Here are some examples of arrays, arraylists, hashtables, and queues.
Subscribe to:
Posts (Atom)