1> Create an ActiveX dll project, rename the project to exampleproject, and rename the class to exampleclass.
2> creation method:
Option explicit
Public Function examplemethod (byval strname as string, byval iage as integer, optional byval bageemphasison as Boolean = false) as string
Dim strreturnstring as string
Strreturnstring = strname & "is over" & CSTR (iage * 365)
If bageemphasison and iage> 45 then
Strreturnstring = strreturnstring & "days old ."
Else
Strreturnstring = strreturnstring & "days old ."
End if
Examplemethod = strreturnstring
End Function
3> compile and generate exampleproject. DL
4> register it with regsvr32.
5> call in ASP:
<%
Set objref = server. Createobject ("exampleproject. exampleclass ")
Name = "silvaxia"
Age = 26
Emphasis = true
Strresult = objref. examplemethod (name, age, emphasis)
Response. Write (strresult)
Set objref = nothing
%>
6> put ASP in a virtual directory and run it.
7> call in. Net:
First Add a reference to exampleproject. DL, and then:
Module module1
Sub main ()
Testcom ()
End sub
Public Function testcom ()
Dim test as exampleproject. exampleclassclass = new exampleproject. exampleclassclass
Console. Write (test. examplemethod ("silvaxia", 67, true ))
End Function
End Module