declare @num int set @num =4 declare @salespersonid int select @num if @num = 3 begin set @salespersonid = (select top 1 Sales.SalesPerson.SalesPersonID from Sales.SalesPerson) end else if @num = 4 begin select 'boo...no 3' end else begin select 'nun of the above' end use AdventureWorks select FirstName, LastName, case emailpromotion when 1 then 'Email Promo' when 2 then 'Text Promo' else 'Leave Me Alone' end promo from person.contact
Wednesday, April 13, 2011
If and Case Statements
Wednesday, April 6, 2011
Practice #5
1. Adding Days of The Week
2. Adding Users
3. Printer Queue
Public Class Form1
Dim week(0 To 6) As String
Private Sub btnShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShow.Click
week(0) = "Monday"
week(1) = "Tuesday"
week(2) = "Wednesday"
week(3) = "Thursday"
week(4) = "Friday"
week(5) = "Saturday"
week(6) = "Sunday"
For Each day As String In week
MsgBox(day)
Next
End Sub
End Class
2. Adding Users
Public Class Form1
Dim Users As New Hashtable
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Users.Add("FirstName", txtFirstName.Text)
Users.Add("LastName", txtLastName.Text)
Users.Add("EMail", 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(Users.Item("FirstName"))
End Sub
Private Sub bntLastName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bntLastName.Click
MsgBox(Users.Item("LastName"))
End Sub
Private Sub btnEmail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEmail.Click
MsgBox(Users.Item("EMail"))
End Sub
End Class
3. Printer Queue
Public Class Form
Dim joblist As New Queue
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
Dim jobs As New Hashtable
jobs.Add("Job Title", txtTitle.Text)
jobs.Add("Page Quantity", NumericUpDown1.Value)
joblist.Enqueue(jobs)
For Each h As Hashtable In joblist
lstJobs.Items.Add("(" & h.Item("Page Quantity") & ")" & h.Item("Job Title"))
Next
jobs.Clear()
joblist.Clear()
txtTitle.Clear()
NumericUpDown1.Value = 1
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
lstJobs.Items.Clear()
End Sub
End Class
Subscribe to:
Posts (Atom)