How to clear a Array ? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to clear a Array ?

Hello,

I am using an string array to store a large text in a for loop. When the control moves to next , i want to clear the array value and store new value.some times the following Error comes.

"un-time error '-2147418113(8000ffff)
scan line index out of range"

Please Help me How to resolve this Problem.

Thanks and Regards,

P.Gerald Manickam

Comments

  • doofusboydoofusboy Posts: 256Member
    : Hello,
    :
    : I am using an string array to store a large text in a for loop. When the control moves to next , i want to clear the array value and store new value.some times the following Error comes.
    :
    : "un-time error '-2147418113(8000ffff)
    : scan line index out of range"
    :
    : Please Help me How to resolve this Problem.
    :
    : Thanks and Regards,
    :
    : P.Gerald Manickam
    :
    :
    Post some of your code, then it may be easier to help you.
  • lionblionb Posts: 1,688Member ✭✭
    [b][red]This message was edited by lionb at 2005-12-7 7:16:45[/red][/b][hr]
    : Hello,
    :
    : I am using an string array to store a large text in a for loop. When the control moves to next , i want to clear the array value and store new value.some times the following Error comes.
    :
    : "un-time error '-2147418113(8000ffff)
    : scan line index out of range"
    :
    : Please Help me How to resolve this Problem.
    :
    : Thanks and Regards,
    :
    : P.Gerald Manickam
    :
    :
    To clear all elements in Array you can use Erase Statement. See code example here:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbenlr98/html/vastmerasex.asp
    To do manipulation with single elements you have to go through the loop and set elements' values to NULL/Empty string. Something like that
    [code]
    Fot I = 0 to Ubound(MyArray)
    If I = 10 Then
    MyArray(I) = vbNullString
    end if
    Next
    [/code]


  • doofusboydoofusboy Posts: 256Member
    : [b][red]This message was edited by lionb at 2005-12-7 7:16:45[/red][/b][hr]
    : : Hello,
    : :
    : : I am using an string array to store a large text in a for loop. When the control moves to next , i want to clear the array value and store new value.some times the following Error comes.
    : :
    : : "un-time error '-2147418113(8000ffff)
    : : scan line index out of range"
    : :
    : : Please Help me How to resolve this Problem.
    : :
    : : Thanks and Regards,
    : :
    : : P.Gerald Manickam
    : :
    : :
    : To clear all elements in Array you can use Erase Statement. See code example here:
    : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbenlr98/html/vastmerasex.asp
    : To do manipulation with single elements you have to go through the loop and set elements' values to NULL/Empty string. Something like that
    : [code]
    : Fot I = 0 to Ubound(MyArray)
    : If I = 10 Then
    : MyArray(I) = vbNullString
    : end if
    : Next
    : [/code]
    :
    :
    :

    Thanks lionb, I had never heard of Erase statement.......learn something new everyday.
  • lionblionb Posts: 1,688Member ✭✭
    :
    : Thanks lionb, I had never heard of Erase statement.......learn something new everyday.
    :
    Sure anytime. I learned about it from somebody on PH couple years ago.
Sign In or Register to comment.