《VB编程技术大全上有个小例子。新建一个ActiveX DLL工程 工程起名为Calendar,类起名为Control 在其类代码中写Option Explicit Public Function IsLeapYear(dYear As Variant) As Boolean If (dYear Mod 4 = 0 And dYear Mod 100 <> 0) Or dYear Mod 400 = 0 Then IsLeapYear = True Else IsLeapYear = False End If End FunctionPublic Function DaysInMonth(dMonth As Variant, dYear As Variant) As Integer Select Case dMonth Case 1, 3, 5, 7, 8, 10, 12 DaysInMonth = 31 Case 4, 6, 9, 11 DaysInMonth = 30 Case 2 If IsDate("February 29," & dYear) Then DaysInMonth = 29 Else DaysInMonth = 28 End If End Select End FunctionPublic Function GetWeekDay(dDate As Variant) As Integer Dim intWeekDay intWeekDay = Weekday(FormatDateTime(CStr(Month(Date) & "/01/" & Year(dDate)), 2)) - 1 If intWeekDay = 0 Then intWeekDay = 7 GetWeekDay = intWeekDay End FunctionASP页面的代码如下<% dim dDate,dDayofMonth,dStartWeekDay,bolLeapYear,objCalendar dDate=FormatDateTime(Date,2) '今天 '建立对象 Set objCalendar=Server.CreateObject("Calendar.Control") bolLeapYear=objCalendar.IsLeapYear(Year(dDate)) dDayofMonth=objCalendar.DaysInMonth(Month(dDate),Year(dDate)) dStartWeekDay=objCalendar.GetWeekday(dDate) Response.write"<p>今天是:"&dDate&"</p>" If bolLeapYear=true Then Response.write"<p>今年是闰年</p>" Else Response.write"<p>今年不是闰年</p>" End If Response.write"<p>当月共有:"&dDayOfMonth&"天</p>" Response.write"<p>当月1号是星期:"&dStartWeekDay&"</p>" %>
调用之前要用regsrv32命令注册calendar.dll
做数据库连接的dll过程差不多不过首先要引用microsoft active data objects 2.6 library和microsoft active server pages object library两个库将sql语句当作方法写道类中可以看看人家的帖子http://expert.csdn.net/Expert/topic/2301/2301728.xml?temp=.8186762
工程起名为Calendar,类起名为Control
在其类代码中写Option Explicit
Public Function IsLeapYear(dYear As Variant) As Boolean
If (dYear Mod 4 = 0 And dYear Mod 100 <> 0) Or dYear Mod 400 = 0 Then
IsLeapYear = True
Else
IsLeapYear = False
End If
End FunctionPublic Function DaysInMonth(dMonth As Variant, dYear As Variant) As Integer
Select Case dMonth
Case 1, 3, 5, 7, 8, 10, 12
DaysInMonth = 31
Case 4, 6, 9, 11
DaysInMonth = 30
Case 2
If IsDate("February 29," & dYear) Then
DaysInMonth = 29
Else
DaysInMonth = 28
End If
End Select
End FunctionPublic Function GetWeekDay(dDate As Variant) As Integer
Dim intWeekDay
intWeekDay = Weekday(FormatDateTime(CStr(Month(Date) & "/01/" & Year(dDate)), 2)) - 1
If intWeekDay = 0 Then intWeekDay = 7
GetWeekDay = intWeekDay
End FunctionASP页面的代码如下<%
dim dDate,dDayofMonth,dStartWeekDay,bolLeapYear,objCalendar
dDate=FormatDateTime(Date,2) '今天
'建立对象
Set objCalendar=Server.CreateObject("Calendar.Control")
bolLeapYear=objCalendar.IsLeapYear(Year(dDate))
dDayofMonth=objCalendar.DaysInMonth(Month(dDate),Year(dDate))
dStartWeekDay=objCalendar.GetWeekday(dDate)
Response.write"<p>今天是:"&dDate&"</p>"
If bolLeapYear=true Then
Response.write"<p>今年是闰年</p>"
Else
Response.write"<p>今年不是闰年</p>"
End If
Response.write"<p>当月共有:"&dDayOfMonth&"天</p>"
Response.write"<p>当月1号是星期:"&dStartWeekDay&"</p>"
%>
建立三层结构的ASP应用程序