473,757 Members | 10,708 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

delete value in array of byte

kirubagari
158 New Member
How about the deletion function.i just modify the insert function to delete function.is it correct.actualy i would like to delete if 04 FF 04 FF (got repeating value) i would like to delete one of the 04 FF.So can i use the function that i modify .The same thing i wana do as insert function but i wana delete this time the condition is if there is repeating value as i mentioned just now.




Expand|Select|Wrap|Line Numbers
  1. Public Function DeleteByte(pmArray() As Byte, pmPosition As Long, ByVal pmNewValue As Byte)
  2. ' Function to delete a new byte value into a byte array.
  3. Dim ArrayStart As Long, ArrayEnd As Long
  4. Dim I As Long
  5. ArrayStart = LBound(pmArray)
  6. ArrayEnd = UBound(pmArray) -1
  7. ' Expand array to make room for the new value.
  8. ReDim Preserve pmArray(ArrayStart To ArrayEnd)
  9. ' If requested position is outside the array, just stick it
  10. ' at the start or end as appropriate.
  11. If pmPosition < ArrayStart Then
  12. pmPosition = ArrayStart
  13. End If
  14. If pmPosition > ArrayEnd Then
  15. pmPosition = ArrayEnd
  16. End If
  17. ' Unless adding to the end of the array,
  18. ' push everything across to make room.
  19. If pmPosition < ArrayEnd Then
  20. For I = ArrayEnd To pmPosition -1 Step -1
  21. pmArray(I) = pmArray(I - 1)
  22. Next
  23. End If
  24. pmArray(pmPosition) = pmNewValue
  25. End Function
Aug 9 '07 #1
36 3508
Killer42
8,435 Recognized Expert Expert
I don't think the code is quite right. But before we get into the code, I'd like you to try and state fairly simply, the method to be used. In other words, can you describe to me, in a fairly simple overview, how you would go about removing a value from the middle of an array?

Turning it into code is quite simple, and we'll get that done quite quickly. But first you have to understand what you're trying to code.

I'll give you a hint. It's not the same sort of process as inserting. If you start by shortening the array, you've just thrown away whatever was at the end of it.
Aug 9 '07 #2
kirubagari
158 New Member
Actualy are u saying that it is not possible to delete the byte in the middle of array.My problem is now

Expand|Select|Wrap|Line Numbers
  1.  04 FF 89 67 87 90 89 04 FF 04 FF 
  2. 89 65 67 78 93 78 78 89 84 67 04
  3.  

i wana delete one of the repeating 04 FF in the array of byte.is it possible in vb?
Aug 9 '07 #3
kirubagari
158 New Member
Actualy when i insert one i have delete one of the 04 FF value in my program

The arrangement of array sometime like 04 FF 04 FF.So when i insert one 04 FF,i should delete one 04 FF.so i have to find the position where should i delete,sowhen there is repeating value like 04 FF 04 FF ,so i wana delete 1 of the 04 FF.So i have to check until EOF to find out the location to be deleted.So i think it will be explain problem more clear.
Aug 9 '07 #4
Killer42
8,435 Recognized Expert Expert
Certainly it's possible to remove a value from the middle of an array. I'd just like you to think about how you would go about removing one from somewhere in the middle.

You might try thinking of the array as a row of boxes, or something similar. What would be the steps involved in taking one out of the middle and not leaving a gap? If you can explain that in detail, you will be very close to writing the code for it.

(Note, here I'm just talking about the actual removal of a byte. This has nothing to do with deciding what byte to remove.)
Aug 9 '07 #5
kirubagari
158 New Member
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. 04 FF F2 03 37 04 04 FF- F1 03 37 04 04 FF F0 03
  4. 37 04 04 FF EF 03 37 04 - 04 FF 04 FF EE 03 37 04
  5. 04 FF ED 03 37 04 04 FF- EC 03 37 04 04 FF EB 03
  6.  
  7.  
For eg i wana find out where the repeating value of 04 FF 04 FF occur,then i wana delete one of the 04 FF
then i wana merge the array.


Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. 04 FF F2 03 37 04 04 FF - F1 03 37 04 04 FF F0 03
  4. 37 04 04 FF EF 03 37 04 - 04 FF EE 03 37 04 04 FF
  5. ED 03 37 04 04 FF EC 03 - 37 04 04 FF EB 03 89 67
  6.  
  7.  
  8.  
This is i wana do after the insertion and do deletion also.How to start?Wana check until EOF and do deletion as the location where there is repeating structure
Aug 10 '07 #6
Killer42
8,435 Recognized Expert Expert
You keep jumping ahead. I'm still trying to get you to spell out how you would go about removing a byte from an array. Let's get working tools before we try to use them, huh?
Aug 10 '07 #7
kirubagari
158 New Member
sir so how if u give a function that delete byte from array as u give me as insertion function.Like delete a value from array of byte as starting so that i can understand more[/font]
Aug 10 '07 #8
kirubagari
158 New Member
how to delete a value from a byte of array.like HELLO.i wana delete the 2nd value.How i can do in vb
Aug 10 '07 #9
Killer42
8,435 Recognized Expert Expert
how to delete a value from a byte of array.like HELLO.i wana delete the 2nd value.How i can do in vb
Now that I think about if further, if you are just looking to replace duplicated strings, I think it will be much simpler to work with a string. You probably won't need the "delete a byte" routine.

Let's assume, for the sake of argument, that you have read your file into string variable strText, instead of a byte array. I think the Replace() function might do the fix for you, all in one go, like so...

Expand|Select|Wrap|Line Numbers
  1. Dim strLookFor As String, strChangeTo As String
  2. strChangeTo = Chr$(&H04) & Chr$(&HFF)
  3. strLookFor = strChangeTo & strChangeTo
  4. strFile = Replace(strFile, strLookFor, strChangeTo)
Aug 10 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2894
by: Shea Martin | last post by:
Which of the following do I use delete instead of just delete. //1.) // not sure about this one, as char is of size 1 char *str = new char; //2.) //not sure about this one, as it is a primitive int *array = new int;
11
912
by: Jonan | last post by:
Hello, For several reasons I want to replace the built-in memory management with some custom built. The mem management itlsef is not subject to my question - it's ok to the point that I have nice and working allocation deallocation routines. However, I don't want to loose the nice extras of new operator, like - constructor calling, typecasting the result, keeping the array size, etc. For another bunch of reasons, outside this scope I...
19
4151
by: jeff | last post by:
how do you convert form byte to Int32 while retaining the binary value of the byte array
8
2529
by: Richard Arthur | last post by:
This is a weird problem. 1) I use MediaDet to save a bitmap in a temporary file. 2) I create a bitmap using that temporary file's name. 3) I use the bitmap. 4) I want to destroy the file when the process exits, but I am having trouble I have written a Finalizer on the object that actually generates the bitmaps, as well as implementing IDisposable. The finalizer gets called, I then call Dispose on each of the bitmaps it the object has...
6
5899
by: Aston Martin | last post by:
Hi All, ********************** My Situation ********************** I am working on project that involves passing a structure to unmanaged code from .Net world (well using C#). Perhaps an example will prove useful. structure MyStruct { // this is a complicated struct declaration in the sense
9
2922
by: Money | last post by:
If I allocate memory like this int *ptr = new int; Can I apply delete ptr; instead of delete ptr; since I am only allocating memory for 1 integer.
29
4252
by: Jon Slaughter | last post by:
Is it safe to remove elements from an array that foreach is working on? (normally this is not the case but not sure in php) If so is there an efficient way to handle it? (I could add the indexes to a temp array and delete afterwards if necessary but since I'm actually working in a nested situation this could get a little messy. I guess I could set there values to null and remove them afterwards? Thanks, Jon
1
1156
kirubagari
by: kirubagari | last post by:
is it possible to do deletion in visual basic. 1.04 FF F2 03 37 04 04 FF - FF 03 37 04 04 FF F0 03.....line 1 2.37 04 04 FF EF 03 37 04 - 04 FF 04 FF EE 03 37 04.....line 2 3.04 FF ED 03 37 04 04 FF - EC 03 37 04 04 FF EB 03....line 3 There is repeating data in the above value.How i can delete the repeating value.When i check it out from byte 49 to mfile size there is repeating data 04 FF.How i can use vb to delete the repetating...
13
5041
by: Tristan Wibberley | last post by:
Hi I've got implementing overloaded operator new and delete pretty much down. Just got to meet the alignment requirements of the class on which the operator is overloaded. But how does one implement operator new/delete I can't see a way to indicate, on delete, how many objects must be destroyed (or how big the space is) - alternatively I can't figure out what are the alignment requirements so that the implementation, after calling my...
0
9298
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9906
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9737
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6562
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5172
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3829
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.