我收到此错误:Microsoft VBScript运行时错误:所需对象:'值'但值有值.为什么?

Dar*_*ren 0 vbscript function asp-classic

我在以下函数中收到标题中的错误:

function ExtractOptions(value)
  dim index

  index = InStr(1, value, ":")
  ExtractOptions = CStr(Mid(value, index + 1, value.length - 1))

end function
Run Code Online (Sandbox Code Playgroud)

但是,当我将监视放在"值"上时,它表明它在ExtractOptions赋值语句中使用时包含一个字符串值,该语句是发生错误的位置.

这是调用代码,以防它提供任何见解:

<%
  if not isnumeric(dictCart(Key)) then 
%>
  <TR>
    <TD id="cart_item_options" class=<%=TextCCSStyle%> ALIGN="left"><%= ExtractOptions(dictCart(Key)) %></TD>
  </TR>    
<% end if %>
Run Code Online (Sandbox Code Playgroud)

Jay*_*ggs 5

问题出在你的电话上value.length.

相反,尝试这个Len功能,如下所示:

ExtractOptions = CStr(Mid(value, index + 1, Len(value) - 1))  
Run Code Online (Sandbox Code Playgroud)