Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Num As Integer
Dim DaysOfWeek(6) As String
DaysOfWeek(0) = "Sunday"
DaysOfWeek(1) = "Monday"
DaysOfWeek(2) = "Tuesday"
DaysOfWeek(3) = "Wednesday"
DaysOfWeek(4) = "Thursday"
DaysOfWeek(5) = "Friday"
DaysOfWeek(6) = "Saturday"
For Num = 0 To DaysOfWeek.Length - 1
MessageBox.Show(DaysOfWeek(Num), "Days")
Next
End Sub
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.
Dim h As New Hashtable
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
h.Add("FirstName", TextBox1.Text)
h.Add("LastName", TextBox2.Text)
h.Add("Email", TextBox3.Text)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
MsgBox(h.Item("FirstName"))
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
MsgBox(h.Item("LastName"))
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
MsgBox(h.Item("Email"))
End Sub
3. 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:
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: remove the next item in the queue and refresh the queue list box.
Dim queue As New Queue
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim h2 As New Hashtable
h2.Add("no", NumericUpDown1.Text)
h2.Add("printing", TextBox4.Text)
queue.Enqueue(h2)
refreshbox()
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
If queue.Count >= 1 Then
queue.Dequeue()
refreshbox()
Else
MessageBox.Show("There is nothing left to clear.", "No! YOU SUCK!!!")
End If
End Sub
Private Sub refreshbox()
ListBox1.Items.Clear()
For Each ht As Hashtable In queue
ListBox1.Items.Add(ht.Item("printing") & "(" & ht.Item("no") & ")")
Next
End Sub
End Class
No comments:
Post a Comment