封装ASP

1、打开Microsoft Visual Basic:

2、修改工程名和类模块的名称:

3、增加到引用asp:工程-->引用

4、编写代码:
在web.cls中输入
'#####################
Option Explicit

Private myContext As ScriptingContext
Private myApplication As Application
Private myResponse As Response
Private myRequest As Request
Private mySession As Session
Private myServer As Server

Public Sub OnStartPage(PassedScriptContext As ScriptingContext)
  Set myContext = PassedScriptContext
  Set myApplication = myContext.Application
  Set myResponse = myContext.Response
  Set myRequest = myContext.Request 
  Set mySession = myContext.Session
  Set myServer = myContext.Server
End Sub

'#########################
在VB中可以像在ASP中实现方法一样,如:
strName=myRequest.Form("name")
myResponse.Write ("Welcome! "&strName)
'######################### 

Public Sub Fun1()
  myResponse.Write "Fun1"
End Sub

Public Sub Fun2(para1 AS String)
  myResponse.Write para1&"<br />Fun2"
End Sub

Public Sub OnEndPage()
  Set myContext = Nothing
  Set myApplication = Nothing
  Set myResponse = Nothing
  Set myRequest = Nothing
  Set mySession = Nothing
  Set myServer = Nothing
End Sub

 

保存在d:\web\dll\web.cls
在把工程保存为d:\web\dll\sample.vbp

5、编译,注册成dll:

6、使用sample.dll:
在ASP中调用组建:
Set objRefer = Server.CreateObject("ProjectName.ClassName")

例如:
Set dll= Server.CreateObject("sample.web")
dll.Fun1
Response.Write "<hr />"
dll.Fun2("This is ")
Response.Write "<hr />"
Set dll = Nothing

posted on 2009-03-19 12:02 Sady 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/sady/archive/2009/03/19/1416471.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值