Coding Thread, Subscript error on vb split function in Coding and Web Development; Hi, I have a string that on an asp page that stores the forename, surname and year of a list ...
1st August 2007, 01:35 PM #1
- Rep Power
Subscript error on vb split function
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)
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.
By alonebfg in forum Wireless Networks
Last Post: 6th November 2008, 02:13 PM
By Lithium in forum Windows
Last Post: 3rd December 2007, 10:57 PM
By alexknight in forum Hardware
Last Post: 7th February 2007, 03:32 PM
By lee_sri in forum Wireless Networks
Last Post: 2nd February 2006, 08:39 PM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)