will store the days of the week. The array should fill when the form loads. Add a button (you can drag it on the
form). When the button is clicked,
loop through the array and pop up a message box for each day of the
week.
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Dim week As New Hashtable
Dim daysofweek As DictionaryEntry
week.Add("1", "Sunday")
week.Add("2", "Monday")
week.Add("3", "Tuesday")
week.Add("4", "Wednesday")
week.Add("5", "Thursday")
week.Add("6", "Friday")
week.Add("7", "Saturday")
For Each daysofweek In week
MsgBox("" & daysofweek.Value)
Next
End Sub
End Class
2. Create a form with textboxes
for the following:
- first name
- last name
- email.
Add labels to describe each box.
Add a button for adding the user. The add user button click event will do the following:
- add the user information
into a hashtable
- clear the text from the
text boxes
We want to add the information into the hashtable using three keys:
FirstName, LastName, Email.
Add First Name, Last Name, and Email buttons to the bottom of the
form. Each of these buttons is
going to fire off a message box that will show the information that was
just added in.
Public Class Form1
Dim adduser As New Hashtable
Private Sub btFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btFirst.Click
MessageBox.Show(txtFirst.Text)
End Sub
Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLast.Click
MessageBox.Show(txtLast.Text)
End Sub
Private Sub btnEmail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEmail.Click
MessageBox.Show(txtEmail.Text)
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
adduser.Clear()
adduser.Add("txtFirst", txtFirst.Text)
adduser.Add("txtLast", txtLast.Text)
adduser.Add("txtEmail", txtEmail.Text)
txtFirst.Clear()
txtLast.Clear()
txtEmail.Clear()
End Sub
End Class
- Create a form that will work
as a printer queue. This form will
have the following inputs: - Title of the
document - Pages to be printed
When
submitted the click event will do the following:
submitted the click event will do the following:
- Add the title and pages to a
hashtable - Add the hashtable to a queue
which is a class variable - Clear the title and set the
pages back to one - Refresh the queue list.
The
Clear Current button will:
Clear Current button will:
- remove the next item in the queue
- Refresh the queue list
box
Public Class Printer
Dim jobs As New Queue
Private Sub btnSendJob_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSendJob.Click
Dim qlist As New Hashtable
jobs.Enqueue(qlist)
qlist.Add("Title", txtTitle.Text)
qlist.Add("Pages", NumericUpDown1.Value)
refreshalljobs()
NumericUpDown1.Value = 1
txtTitle.Text = ""
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
If jobs.Count > 0 Then
jobs.Dequeue()
End If
refreshalljobs()
End Sub
Private Sub refreshalljobs()
qlist.Items.Clear()
For Each hash As Hashtable In jobs
qlist.Items.Add(hash.Item("Title") & "(" & hash.Item("Pages") & ")")
Next
End Sub
End Class
No comments:
Post a Comment