PWSK- Handler.ashx

The Handler.ashx is used to dynamically return a image from a query string. Http handler is similar to regular web form, only faster (~10%, compare with web form) with less functionality.
IsReusable property is usually set to be true to reduce memory footprint and improve performance.
In the sample application pictures are taken from a database. If one prefer to use file system instead then the handler can be changed to.
HttpResponse r = context.Response;
r.ContentType = "image/png";
r.WriteFile("Logo1.png");

Personal Website Starter Kit

It is going to be a summary of my PWS learning experience.
First some links that I read during the process.

Due to some reason, all connections are NOT closed in PhotoManager.cs after query execution. I will write a common data access code (a static class) to deal with it.

class collection in VBA


Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in D:\InetPub\vhosts\kwu-1639.package\kennywu.info\wwwroot\wp-content\plugins\wp-syntax\wp-syntax.php on line 380

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in D:\InetPub\vhosts\kwu-1639.package\kennywu.info\wwwroot\wp-content\plugins\wp-syntax\wp-syntax.php on line 380

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in D:\InetPub\vhosts\kwu-1639.package\kennywu.info\wwwroot\wp-content\plugins\wp-syntax\wp-syntax.php on line 380

It takes more effect to set up you collection in a class module but it will make your code more portable and easier to maintain.
Employee class

Option Explicit
 
Private FName As String
Private FHoursPerWeek As Double
Private FRate As Double
 
Public Function GetGrossWeeklyPay() As Double
    GetGrossWeeklyPay = FHoursPerWeek * FRate
End Function
 
Public Property Get Name() As String
    Name = FName
End Property
 
Public Property Get HoursPerWeek() As Double
    HoursPerWeek = FHoursPerWeek
End Property
 
Public Property Get Rate() As Double
    Rate = FRate
End Property
 
Public Property Let Name(v As String)
    FName = v
End Property
 
Public Property Let HoursPerWeek(v As Double)
     FHoursPerWeek = v
End Property
 
Public Property Let Rate(v As Double)
    FRate = v
End Property

Emoployees class

Option Explicit
 
Private FEmployees As New Collection
Public Function Add(ByVal value As Employee)
    Call FEmployees.Add(value, value.Name)
End Function
 
Public Property Get Count() As Long
    Count = FEmployees.Count
End Property
 
Public Property Get Items() As Collection
    Set Items = FEmployees
End Property
 
Public Property Get Item(ByVal v As Variant) As Employee
    Set Item = FEmployees(v)
End Property
 
Public Sub remove(ByVal v As Variant)
    Call FEmployees.remove(v)
End Sub

test module

Option Explicit
Dim theEmployees As New Employees
 
Sub testEmployeesCollection()
    Dim anEmployee As Employee
    Dim I As Long
 
    For I = theEmployees.Count To 1 Step -1
        Call theEmployees.remove(I)
    Next I
 
    Set anEmployee = New Employee
    anEmployee.Name = "Paul Kimmel"
    anEmployee.Rate = 15
    anEmployee.HoursPerWeek = 45
    Call theEmployees.Add(anEmployee)
 
    Set anEmployee = New Employee
    anEmployee.Name = "Bill Gates"
    anEmployee.Rate = 13
    anEmployee.HoursPerWeek = 56
    Call theEmployees.Add(anEmployee)
 
    Debug.Print "number of employees = " & theEmployees.Count
    Debug.Print "employees(2) = " & theEmployees.Item(2).Name
    Debug.Print "employees(paul kimmel rate) = " & theEmployees.Item("Paul Kimmel").Rate
    For Each anEmployee In theEmployees.Items
        Debug.Print anEmployee.Name & "earns $" & anEmployee.GetGrossWeeklyPay()
    Next anEmployee
End Sub