日期:2014-05-17  浏览次数:20798 次

用VB封装asp的DLL时候,ASP的execute 如何封装?
用VB封装asp的DLL时候,ASP的execute   如何封装?

直接用   execute( "response.write   " "hello   world " "   ")   不成功!

不知道大家有没有好的方法?

------解决方案--------------------
直接response.write 不行么?
------解决方案--------------------
Eval试下呢?
------解决方案--------------------
学习~···
------解决方案--------------------
Option Explicit

'你的自定义的变量
Private MyVar

'必须先在工程中引用 Microsoft Script Control 1.0

Private vbs As New MSScriptControl.ScriptControl

'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
'以下部分不要更改
Private ScriptingContext As ScriptingContext
Private Application As Application
Private Request As Request
Private Response As Response
Private Server As Server
Private Session As Session
Public Sub OnStartPage(PassedScriptingContext As ScriptingContext)
Set ScriptingContext = PassedScriptingContext
Set Application = ScriptingContext.Application
Set Request = ScriptingContext.Request
Set Response = ScriptingContext.Response
Set Server = ScriptingContext.Server
Set Session = ScriptingContext.Session
End Sub
Public Sub OnEndPage()
Set ScriptingContext = Nothing
Set Application = Nothing
Set Request = Nothing
Set Response = Nothing
Set Server = Nothing
Set Session = Nothing
End Sub
'以上部分不要更改
'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA


Public Sub Test()
MyVar = App.Title
Response.Write "Hello VB6 for ASP Component Demo: " & MyVar
Response.Write " <br> "
Response.Write "Return from inner VBScript: "
'定义内部的VBScript
vbs.Language = "VBScript "
'执行内部的VBScript
vbs.ExecuteStatement "dim a : Execute " "a=5 " " "
'返回内部VBScript的结果
Response.Write vbs.Eval( "a ")
End Sub

------解决方案--------------------
'而且还可以这样调用来玩VBScript:
Public Sub Test()

'定义内部脚本语言为 VBScript
vbs.Language = "VBScript "

'将ASP默认对象传递给内部脚本
vbs.AddObject "ScriptingContext ", ScriptingContext, True
vbs.AddObject "Response ", Response, True
vbs.AddObject "Request ", Request, True
vbs.AddObject "Server ", Server, True
vbs.AddObject "Session ", Session, True

'执行内部脚本
vbs.ExecuteStatement "dim fso : set fso=Server.CreateObject( " "Scripting.FileSystemObject " ") : Execute " "Response.Write fso.GetTempName() " " "

End Sub