|
-
Jun 29th, 2007, 03:25 PM
#1
Thread Starter
New Member
[RESOLVED] Clearing a Structure
Hi trying to check I have cleared this correctly. Seems to have worked byt I seem to get anomolies somethimes that might have nothing to do with the clear part.
I declare the structure. Dimension it, then when I need to clear call the Sub to clear it.
1) Will this clear it all, including the array within the structure?
2) Incidentally I dimension it after as it is here in the example. Is there a way of doing it when actually needed so I have a better idea of how many items to allocate as opposed to an arbitrary number as here in the example of 30?
Code:
Structure TestList
Dim TL_name As String
Dim TL_total As Integer
Dim TL_Sub_total_Array() As Integer
Dim TL_reference As Integer
End Structure
Dim TotalList(30) As TestList
Private Sub Clear_Rows_Display()
Dim count1 As Integer
For count1 = 0 To TestList.GetUpperBound(0)
Array.Clear(TestList, 0, count1)
Next
End Sub
Thanks in advance.
Last edited by Writers Block; Jul 2nd, 2007 at 05:04 AM.
-
Jun 29th, 2007, 03:47 PM
#2
Re: Clearing a Structure
Use an array list instead. Then just .Add to it as you need to.
-tg
-
Jun 30th, 2007, 12:07 PM
#3
Thread Starter
New Member
Re: Clearing a Structure
 Originally Posted by techgnome
Use an array list instead. Then just .Add to it as you need to.
-tg
Array list?
-
Jun 30th, 2007, 01:46 PM
#4
Re: Clearing a Structure
 Originally Posted by Writers Block
Array list?
http://msdn2.microsoft.com/en-us/lib...st(vs.80).aspx

EDIT: Changed to Framework 2.0 link.
Last edited by nmadd; Jun 30th, 2007 at 02:27 PM.
Reason: changed link
-
Jun 30th, 2007, 02:23 PM
#5
Re: Clearing a Structure
i always erased my arrays with a ReDim but you have to declare it as dynamic to do that.
That page states that the information on it is for .net 3.0
that distributable is currently Beta. some people have it but it won't even be available on all OS.
-
Jun 30th, 2007, 02:28 PM
#6
Re: Clearing a Structure
if you don't know how, here's an example of redimming
Code:
Structure TestList
Dim TL_name As String
Dim TL_total As Integer
Dim TL_Sub_total_Array() As Integer
Dim TL_reference As Integer
End Structure
dim TotalList() as Testlist 'dims it dynamic
ReDim TotalList(30) As TestList'sets it to size
Private Sub Clear_Rows_Display()
redim TotalList(30) as testlist 'erases it
' Redim preserve totallist(3) as testlist 'Doesn't erase it
End Sub
Last edited by Lord Orwell; Jun 30th, 2007 at 02:38 PM.
Reason: forgot code brackets
-
Jun 30th, 2007, 02:31 PM
#7
Re: Clearing a Structure
 Originally Posted by Lord Orwell
i always erased my arrays with a ReDim but you have to declare it as dynamic to do that.
That page states that the information on it is for .net 3.0
that distributable is currently Beta. some people have it but it won't even be available on all OS.
You're right. The MSDN search turns up articles for all versions and I clicked on the 3.0 version. Changed.
-
Jun 30th, 2007, 05:58 PM
#8
Re: Clearing a Structure
If you are using .NET 2.0 then use a List(Of TestList) instead.
-
Jul 2nd, 2007, 05:03 AM
#9
Thread Starter
New Member
Re: Clearing a Structure
Thank you for your replies.
Got it sorted now(i think).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|