注册 登录
编程论坛 ASP技术论坛

下标越界

finaly 发布于 2008-04-27 13:21, 724 次点击
<%  set rsc=conn.execute("select content  from company where id=1")
    content=rsc("content")
    rsc.close
    set rsc=nothing    
    
    'str=split(content,chr(13))
    'response.Write(ubound(str))
    
Function text1(fString1)'选取段落函数
  num=1 '定义显示几段
 If Not IsNull(fString1) Then
    str=split(fString1,chr(13))    
    for n=0 to 1
    fString=fString&str(n)&"<br>"
    next
    text1 = fString
   
  End If
End Function    
%>
<%= text1 (content) %>
----------------------------
错误提示:
错误类型:
Microsoft VBScript 运行时错误 (0x800A0009)
下标越界: 'n'
-----------------
这是因为我的content里面是空的,或者没有回车。这种情况请问怎么显示呀
3 回复
#2
tianyu1232008-04-27 14:19
改为这样试试
Function text1(fString1)'选取段落函数
  num=1 '定义显示几段
If fString1<>"" Then
    str=split(fString1,chr(13))   
    for n=0 to 1
    fString=fString&str(n)&"<br>"
    next
    text1 = fString
else
    text1=fString1
End If
End Function
#3
makebest2008-04-27 20:59
很简单,检测数组的最小和最大下标就行了
for n=lbound(str) to ubound(str)
#4
hxfly2008-04-27 23:30
for n=0 to ubound(str)-1
这样就可以了
1