Solved

delete a range of values from array and resize

Posted on 2007-03-22
3
148 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now