vb.net Clear Array
-
Saturday, December 13, 2008 7:26 PM
Can any one help, I am trying to clear an array info(8), set all components to zero, nothing.
Erase info causes failures with subsequent functions.
I have searched books and msdn forums without success.
The only reference I have found: [Call System.Array.Clear(info, info.GetLowerBound(0), info.Length)]
Unfortunately this don’t work .
All Replies
-
Saturday, December 13, 2008 7:44 PM
What more do you want this:Array.Clear(Info, Info.GetLowerBound(0), Info.Length)
to do?
It sets all elements of the array to Nothing. There isn't much more that can be done unless you want to fill the array with some initializer.- Marked As Answer by hemo Saturday, December 13, 2008 11:09 PM
-
Saturday, December 13, 2008 9:37 PMI have tried,
Array.Clear(Info, Info.GetLowerBound(0), Info.Length) which returns an error ' Index was outside the bounds of the array'
hemo -
Saturday, December 13, 2008 9:56 PMWhy are you getting that error? Put a breakpoint on that line to find out. What are the bounds of the array?
-
Saturday, December 13, 2008 11:09 PMSorry made a stupid error. The code works fine. Thanks for your patience.
-
Sunday, December 14, 2008 7:46 AMHi ALL,
An array can only have a lower bound of zero so why not simply use.>>
Dim info(0 To 20) As Integer
Array.Clear(info, 0, info.Length)
Regards,
John
For links to VB.Net tutorials see here.>> http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/29f2179b-997b-4115-a96d-a0834853b835- Edited by John Anthony Oliver Sunday, December 14, 2008 7:49 AM ....
-
Sunday, December 14, 2008 3:02 PM
That’s progress. Thanks
hemo
-
Wednesday, January 21, 2009 4:35 PM
Hi,
I've declared a array inside the structure and i want to clear that array from other function. Here is my program,
Public class()
Public Structure KBCContents
Dim DEF_Array() As String 'Declare DEFinition Array
Dim ValueTable As String 'Declare ValueTable
End StructurePublic Function process()
Process step 1...
Process step 2...
Process step 3...
Clear()
End Function()Sub clear()
Dim ClearStructureData As New KBCContents
ClearStructureData.DEF_Array()="" ' This is not working; Need to know how to clear this array; also array size is not known.
End SubEnd Class()
Let me know, how to clear "DEF_Array()" array contents
Thanks,
-Baskar
Measurment & Automation Platform -
Wednesday, January 21, 2009 5:00 PM
Baskar:
You should start a new thread and post your initialization code for the structure.

