Converting from UDT to structure or object - please help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Clark Stevens

    Converting from UDT to structure or object - please help

    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?

    All suggestions welcome


  • Klaus H. Probst

    #2
    Re: Converting from UDT to structure or object - please help

    That's OK as long as you're not going to change the number of items in the
    array, because .NET arrays are immutable.

    But you can use an ArrayList, or a Hashtable or any of the other container
    classes.

    But your approach is pretty much there.


    --
    Klaus H. Probst, MVP



    "Clark Stevens" <cyberbeat03@ho tmail.com> wrote in message
    news:9BiCc.1147 51$j24.5372@twi ster.nyroc.rr.c om...[color=blue]
    > I have a program that I'm converting from VB6 to VB.NET. It reads in a[/color]
    text[color=blue]
    > file containing barcode numbers and their corresponding descriptions.[/color]
    Then[color=blue]
    > 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[/color]
    description.[color=blue]
    > 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?
    >
    > All suggestions welcome
    >
    >[/color]


    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Converting from UDT to structure or object - please help

      * "Clark Stevens" <cyberbeat03@ho tmail.com> scripsit:[color=blue]
      > 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?[/color]

      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/>

      Comment

      • Mike McIntyre [MVP]

        #4
        Re: Converting from UDT to structure or object - please help

        The article at the link below should be helpful.



        --
        Mike

        Mike McIntyre
        Visual Basic MVP



        "Clark Stevens" <cyberbeat03@ho tmail.com> wrote in message
        news:9BiCc.1147 51$j24.5372@twi ster.nyroc.rr.c om...[color=blue]
        > I have a program that I'm converting from VB6 to VB.NET. It reads in a[/color]
        text[color=blue]
        > file containing barcode numbers and their corresponding descriptions.[/color]
        Then[color=blue]
        > 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[/color]
        description.[color=blue]
        > 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?
        >
        > All suggestions welcome
        >
        >[/color]


        Comment

        • Clark Stevens

          #5
          Re: Converting from UDT to structure or object - please help

          "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
          news:2jtuskF15k sauU4@uni-berlin.de...[color=blue]
          > 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.[/color]

          This program will be used with a barcode scanner as well. I don't
          anticipate there being a lot of records, so it sounds like I am on the right
          track here. I thank you, and everyone else who responded, for your help.
          This newsgroup is great!


          Comment

          Working...