Jump to content

Recommended Posts

Posted

Hi, I have a string that on an asp page that stores the forename, surname and year of a list of pupils; each bit is seperated by an _ and each individual person by a |. For example Bob_smith_7|john_jones_8.

 

Using the split function I've seperated each person into an array:

MyArray(0) = Bob_smith_7

MyArray(1) = john_jones_8.

This bit works fine.

 

However when I come to split forename, surname and year it up I get a subscript error. The code is basically doing a For Next Loop for Each person in the Array, splitting their details into a second array; MyArray2 = Split(Myarray(i)), and then printing the forename and surname on the page.

 

If i do for example:

response.write MyArray2(0) i get a subscript error.

However if I do

----

For i = 0 to ubound(MyArray2)

response.write MyArray2(i)

Next

---

This works.

 

What's causing the error when I try and access an element in the array directly, but doesn't cause the error when being done in a For Next loop?

 

Hope this all makes sense, and if you want to see the propper source code view the attached file.

 

Many thanks.

Ryan

split_error.txt

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...