TechArena Community

TechArena Community (
-   Software Development (
-   -   Array subscript issue in VB 6 (

Harshini 06-04-2009 04:38 PM

Array subscript issue in VB 6
Hello friends,

I am facing an issue with my code, whenever i am trying to store any data by splitting a string, I am receiving script out of range error and error in nstr variable.

Can anyone fix this error for me.

Modifier 06-04-2009 04:40 PM

Re: Array subscript issue in VB 6
Sure i will help you you out with this before that can i get your code, with would be helpful for me to fix your issue.

Harshini 06-04-2009 04:42 PM

Re: Array subscript issue in VB 6
Here is the code in which i ma getting the error.


dim mstr() as string
dim nstr() as string
dim nstring as string

mstr = Split(nstring, vbctrlf)
For j = LBound(mstr) To UBound(mstr)
If nstr(LBound(nstr)) = " " Then
nstr(UBound(nstr) + 1) = mstr(j)
For k = LBound(nstr) To UBound(nstr)

Modifier 06-04-2009 04:48 PM

Re: Array subscript issue in VB 6
As i can see in the code is that you need to provide a size for the array variable nStr() which you have defined it as undimensioned and to dimension an array on the fly you use the redim statement.

Use Split() function in Str() array variable. The Split() function automatically dimensions and fills a string array. The lower bound is always 0 when you do this.

All times are GMT +5.5. The time now is 08:01 AM.