【问题标题】:VBScript runtime error '800a000d' Type mismatch when calling Function调用函数时 VBScript 运行时错误“800a000d”类型不匹配
【发布时间】:2014-09-25 02:56:23
【问题描述】:

我复制了一个剥离 html 的函数,并在代码中添加了一些额外的替换,但是当我在任何地方调用此函数时,此代码出现错误

stripHTML(objRS("Name"))输入为字符串,如何切换或清除类型?

Microsoft VBScript 运行时错误“800a000d”类型不匹配:“stripHTML”

--function.asp

function stripHTML(strHTML)
  Dim objRegExp, strOutput, tempStr
  Set objRegExp = New Regexp
  objRegExp.IgnoreCase = True
  objRegExp.Global = True
  objRegExp.Pattern = "<(.|n)+?>"
  'Replace all HTML tag matches with the empty string
  strOutput = objRegExp.Replace(strHTML, "")
  'Replace all < and > with &lt; and &gt;
  strOutput = Replace(strOutput, "<", "&lt;")
  strOutput = Replace(strOutput, ">", "&gt;")
  strOutput = Lcase(replace(replace(trim(strOutput),"/","-")," ","-"))
  strOutput = replace(replace(replace(strOutput,".","-"),"&","-"),",","")
  strOutput = replace(replace(strOutput,"--","-"),"---","-")
  stripHTML = strOutput    'Return the value of strOutput
  Set objRegExp = Nothing
end Function

更新

我调用这个函数的地方是另一个在顶部包含这个页面的文件

有时这个函数会被另一个文件调用这个页面正在拉取(例如:页脚模板)

如何使此功能可全局访问?

【问题讨论】:

  • objRS("Name") 可能为 NULL。您可以在 SQL 查询中防范这种情况:select isnull(Name, '') ...
  • 它们的值在 do while not objRS.EOF 内部,并从已经工作的东西转换代码。 @邦德

标签: vbscript


【解决方案1】:

正如已经指出的那样,您仍然需要处理 NULL(s),否则请尝试:

stripHTML(CStr(objRS("Name")))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多