Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

delete a range of values from array and resize

Posted on 2007-03-22
3
150 Views
Last Modified: 2010-04-23
I have a byte array that holds 100 values, i search through and find 20 values that i copy to a new array, then i need to delete the values from the original array and resize it.
Here is what i have so far.

'byte array to hold the chunk
                Dim bytChunk As Byte()
                'make it the needed size
                ReDim bytChunk(shrtTailIndex - shrtHeadIndex)
                'copy the bytes from the ring buffer to the chunkbuffer
                Array.Copy(bytRingBuffer, shrtHeadIndex, bytChunk, 0, bytRingBuffer.Length)


What i need to know is how to delete the array of values and then resize it so there is no blank space inside if that would be the case

VB.NET VS2005

Thanks!!
0
Comment
Question by:Halon
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
Christopher Kile earned 500 total points
ID: 18774294
Add these lines:

Array.Copy(bytRingBuffer, shrtTailIndex + 1, bytRingBuffer, shrtHeadIndex, bytRingBuffer.Length - (shrtTailIndex + 1))
Redim Preserve byt((bytRingBuffer.Length - 1) - (shrtTailIndex - shrtHeadIndex + 1))

I tested this using { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } with shrtHeadIndex = 3 and shrtTailIndex = 6 and got { 0, 1, 2, 7, 8, 9 }
0
 

Author Comment

by:Halon
ID: 18774364
Worked like a charm!!

Thanks!
0
 
LVL 23

Expert Comment

by:Christopher Kile
ID: 18774488
yvw :)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question