>Is this a correct way to remove an item from a Boolean array?
>
[quoted text clipped - 21 lines]
>Thanks,
>Ed
P.S. , I replaced CopyMemory with RtlMoveMemory and seems to be working
OK now, still not sure if this is the correct way of doing it, never
used these APIs before.
Thanks for any tips,
Ed
Ed <nospam@hotmail.com> schrieb im Beitrag
<mk02a3l1e6476q5a8fanv9poltf2i9nlac@4ax.com>...
> Is this a correct way to remove an item from a Boolean array?
>
[quoted text clipped - 4 lines]
>
> End Sub
Private Sub RemoveElement_Bool(AryVar() As Boolean, ByVal Index As Long)
Dim Count As Long, IndexMax As Long
On Error Resume Next
IndexMax = UBound(AryVar)
Count = IndexMax - LBound(AryVar) + 1
On Error Goto 0
If Count = 0 Then
Exit Sub
Else If (Index < LBound(AryVar)) Or (Index > IndexMax) Then
Exit Sub
End If
Count = Count - 1
If Count = 0 Then
Erase AryVar
Else
If Index < IndexMax Then
CopyMemory ByRef AryVar(Index), _
ByRef AryVar(Index + 1), _
Len(AryVar(Index)) * Count
End If
ReDim Preserve AryVar(LBound(AryVar) To (IndexMax - 1))
End If
End Sub
But this as well is not the 'correct' way since CopyMemory() bypasses the
type checking and securing methods of VB. 'Correct' would be moving of the
array items in a loop without using CopyMemory().

Signature
----------------------------------------------------------------------
THORSTEN ALBERS Universität Freiburg
albers@
uni-freiburg.de
----------------------------------------------------------------------
Thorsten Albers - 20 Jul 2007 23:35 GMT
Thorsten Albers <albersRE@MOVEuni-freiburg.de> schrieb im Beitrag
<01c7cb01$de70f8e0$6401a8c0@xyz>...
> On Error Resume Next
> IndexMax = UBound(AryVar)
> Count = IndexMax - LBound(AryVar) + 1
> On Error Goto 0
Sorry, this should read:
On Error Resume Next
Count = UBound(AryVar) - LBound(AryVar) + 1
If Count Then IndexMax = UBound(AryVar)
On Error Goto 0

Signature
----------------------------------------------------------------------
THORSTEN ALBERS Universität Freiburg
albers@
uni-freiburg.de
----------------------------------------------------------------------