dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Need help with a barcode scanner

  1. #1
    Join Date
    May 2018
    Posts
    1

    Need help with a barcode scanner

    I;m making a program that scans a food products barcode and inserts it into a textbox. The progam will then tell you where the food was made. This is done by the first 3 digits of the barcode as it tells us where the product was made.
    My question???? How to I essentially pull just these 3 digits out to use as im not interested in the other numbers. I just want the program to recognise the first 3 so it can compare it to a datbase of which country it come from???????
    Thanks guys

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,303

    Re: Need help with a barcode scanner

    Well you could use either Left$() or Mid$() to get the portion you want assuming you are talking about working with the data after it is in the textbox then it might look something like this.

    Code:
    FirstThree=Left$(Text1.Text,3)
    The also assumes that you mean the first 3 characters If you actually need the first 3 digits and something else precedes those digits then some tweaking would be required and perhaps use Mid$() instead of Left$() as mid lets you specify both the starting point and number of characters.

    Typically I would configure the scanner to send a CR after the data and then check for a CR in the keypress event to trigger the code. That way the code will execute after each scan with no user intervention.
    Always use [code][/code] tags when posting code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)