473,320 Members | 1,600 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Best way to search an array for a value and return offset position

3
I have a binary file loaded into a byte array (which might need to be converted to a string). I am trying to enter a value in Txtbx2 and search the array, when found return the offset where it was found. Is there a way I can alter the code below to work or is there another way?

Expand|Select|Wrap|Line Numbers
  1. Dim [Data] As Byte() = New Byte() {1, 2, 4, 6, 3}
  2.         Dim find As Byte = TextBox2.Text
  3.         Dim index As Integer = System.Array.IndexOf(Of Byte)([Data], find)
  4.  
  5.         If (index = -1) Then
  6.             MessageBox.Show("Not Found")
  7.             'Not found...
  8.         Else
  9.             'Found
  10.             TextBox3.Text = index
  11.         End If  
Oct 22 '14 #1
4 1236
iam_clint
1,208 Expert 1GB
Are you trying to find a byte array or an individual byte? or what are you trying to accomplish really?
Oct 22 '14 #2
King96
3
Im trying to search a byte array for a particular byte and then return the offset where it is located and do so for every instance that specific byte is used in a binary file
Oct 23 '14 #3
If you want to search many times, you may sort it and perform binary search.
Oct 23 '14 #4
King96
3
I figured out how to return the decimal offset or block. Now I have to figure out how to loop it to continue searching, and how to properly print the output
Oct 23 '14 #5

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

Similar topics

1
by: Phil Powell | last post by:
$successMsgArray = array('image' => array('add_album' => 'Album: "$album" has been created', 'edit_album' => 'Information for album "$album" has been changed')); I am having to return the...
8
by: Mike S. Nowostawsky | last post by:
I tried using the "toUpperCase()" property to change the value of an array entity to uppercase BUT it tells me that the property is invalid. It seems that an array is not considered an object when...
5
by: Andrew Poulos | last post by:
If I'm searching for an occurance of a value in a multi-dimensional array how can I get it's index returned as an array, if found? For example, if: foo = new Array(); foo = , 5, , 9, 10]; ...
1
by: JAG | last post by:
I am getting an error using the replace method in one of my functions. I am using the replace method in the mail document function in my frameset .hta to change forward slashes to back slashes in...
11
by: MLH | last post by:
The following procedures found at http://ffdba.com/downloads/Send_Mail_With_Outlook_Express.htm are meant to work together in harmony to effect eMail sends via OE. The last procedure (FN SplitB)...
4
by: IRC | last post by:
hey, i am pretty new on javascript as well as PHP, Hey, anyone can you help me, how to pass the javascript array value to php page......... i want to retrieve the values which are arrayed on...
1
by: vinodkus | last post by:
dear sir/madam I want to show javascript array value in asp combo. please help me or give me a proper link. Thanks in Advance. Bye
4
by: neoform | last post by:
I was wondering what would be the best search application for indexing/ searching content? Fulltext in MySQL is too slow once you get a db over 1GB. I played around with Zend's version of Lucene,...
4
by: toadstool | last post by:
I have an array containing the various products $inventory = array(); $inventory = "whatever1"; etc I have an array containing various values $quantity = array(100,200,300); I call in a...
1
by: Mary meer | last post by:
i am trying to switch array value but i get this error message: Undefined offset 2 $at=array( array('Title:','title',2,10), array('First Name:','fname',2,10 ), ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.