Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-04-2013, 01:26 AM   PM User | #1
lebronletchev
Regular Coder

 
Join Date: Oct 2006
Location: Spain
Posts: 147
Thanks: 2
Thanked 0 Times in 0 Posts
lebronletchev is an unknown quantity at this point
Subscript out of range

Hi,

I have a database with a memofield from which I get the entire string after searching the whole text using a keyword (single or complex), but I have a problem, depending on the character in the string, the asp script shows an error:
Quote:
Microsoft VBScript runtime error '800a0009' Subscript out of range: '[number: 2]'

Examples:

by eighteen fifteen, five thousand chronometers were in use on ships sailing the world's oceans.
the twenty-six year old singer says her music attempts to reach out for an understanding of othe people's experiences

The output string stop here with the above error message.



MY CODE:

Quote:
<%For n = 0 to 3%>
<% mystring = rs1("texts") %>
<% myword = strkeyword %>
<% myarray = Split(mystring, myword, 3, 1) %>
<%next%>
<TABLE border=0>
<TR>
</TR>
<TR>
<TD width=49% align=right><%Response.Write "<font size=1 face=verdana ><b>" & MyArray(0) & "</b></font>" %> </TD>
<TD width=1% bgcolor=yellow><%response.write "<font size=1 face=verdana ><b>" & MyWord & "</b></font>" %></TD>
<TD width=49%><%response.write "<font size=1 face=verdana ><b>" & Myarray(2) & "</b></font>" %> </TD>
<TD width=1%><%'response.write "<font size=1 face=verdana ><b>" & rs1("fileid") & "</b></font>" %> </TD>

</TR>
</TABLE>



How I fix the error or hidden the error message?


Thanks in advance for any thoughts.

Lebron

Last edited by lebronletchev; 02-04-2013 at 01:40 AM..
lebronletchev is offline   Reply With Quote
Old 02-04-2013, 09:05 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,248
Thanks: 59
Thanked 3,999 Times in 3,968 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
The error means that there is *NO* element 2 in the array.

That is, your SPLIT did *NOT* create at least 3 parts.

But your code makes NO SENSE anyway:
Code:
<%
For n = 0 to 3
    mystring = rs1("texts") 
    myword = strkeyword 
    myarray = Split(mystring, myword, 3, 1) 
Next
%>
The code does the SAME THING THREE TIMES!

WHY? NOTHING changes in the 3 iterations.

Maybe you should DEBUG???

Code:
<%
mystring = rs1("texts") 
Response.Write "DEBUG: mystring is ::" & mystring & "::<hr/>"
myword = strkeyword 
Response.Write "DEBUG: myword is ::" & myword & "::<hr/>"
myarray = Split(mystring, myword, 3, 1) 
Response.Write "DEBUG: UBound(myarray) is " & UBound(myarray) & "<hr/>"
%>
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:53 AM.


Advertisement
Log in to turn off these ads.