Solved

delete a range of values from array and resize

Posted on 2007-03-22
3
151 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
[X]
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
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

733 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