Dim week As New Hashtable 'declare at class leve
Dim day As DictionaryEntry
week.Add("Sunday", "Day 1")
week.Add(Monday", "Day 2")"
week.Add(Tuesday", "Day 3")"
week.Add(Wednesday", "Day 4")"
week.Add(Thursday", "Day 5")"
week.Add("Friday", "Day 6")"
week.add("Saturday", "day 7")'Display a single Item
MsgBox(day.Key)For Each day In week
Next
txtTitle.Text = ""
Friday, April 1, 2011
Array Project (days of the week)
Days of the week Project
Array Project *revised
Here is an example of a Printer Queue:
In this example i am going to demonstrate how to create an array that will store users; Name(first and last), and Email address.
Dim printJobs As New Queue
Private Sub btnSendJob_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSendJob.Click
Dim printer As New Hashtable
printer.Add("Title", (txtTitle.Text))
printer.Add("Pages", (cbPages.Text))
printJobs.Enqueue(printer)
lstJobs.Items.Clear()
For Each h As Hashtable In
printJobs
lstJobs.Items.Add(h.Item("Title") & " " & (h.Item("Pages")))
Next
txtTitle.Text = ""
Me.cbPages.Items.Remove("")
End Sub
Private Sub btnClearCurrent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClearCurrent.Click
lstJobs.Items.Clear()
End Sub
End Class
In this example i am going to demonstrate how to create an array that will store users; Name(first and last), and Email address.
Dim Names As New Hashtable
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Names(1) = (txtFirstName.Text)
Names(2) = (txtLastName.Text)
Names(3) = (txtEmail.Text)
txtEmail.Clear()
txtFirstName.Clear()
txtLastName.Clear()
End Sub
Private Sub btnFirstName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirstName.Click
MsgBox(Names(1))
End Sub
Private Sub btnLastName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLastName.Click
MsgBox(Names(2))
End Sub
Private Sub btnEmail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEmail.Click
MsgBox(Names(3))
End Sub
End Class
Subscribe to:
Posts (Atom)