* "Clark Stevens" <cy*********@hotmail.com> scripsit:
I have a program that I'm converting from VB6 to VB.NET. It reads in a text
file containing barcode numbers and their corresponding descriptions. Then
the user enters the barcode number and the program finds the matching
barcode description.
In VB6 I used an UDT to store the barcode number along with the description.
Then I declared an array of the barcode UDT.
I'm thinking of converting the UDT to a structure in VB.NET and doing
something like this:
Structure BCStructure
BCNumber as Integer
BCDescription as String
End Structure
Public BC() as BCStructure
Is there a more efficient way to handle this in VB.NET? Should I setup a
barcode class and use an object collection instead? What are the
advantages/disadvantages?
If that's a good solution depends on the number of barcodes. These days
we finished a project for university (written in Java :-() that was
connected to a barcode scanner to scan barcodes placed on walls. We
only had 10 barcodes in our sample, and there will never be more than
100 barcodes. So we simply used a text file containing the number
followed by a tab and followed by the description or a filename and
loaded it into an array/collection. Then we used linear search to find
the item.
Your records are very small, and if there are only few of them, using an
array is IMO a good solution. For string IDs, I would use a hashtable,
but that's not the case for simple barcode scanners. If there are lots
of items and managing them and searching is a complicated process, using
a database may be the better solution.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>