Make a program in Visual Basic to look up item in database by typing UPC barcode?
Make a program in Visual Basic to look up item in database by typing UPC barcode?
I have a CSV (comma separated value) file with UPC Barcodes in it. I want to know how to make a visual basic program that will show the name of the item when the barcode is entered. 10 points for a step by step instruction guide or working link.
:)
just a small visual basic program for an experiment. not for commercial use so no-one recieves anything (like profits etc)
Best answer:
{ Geeze. When is this project due Vern? Is it gonna need a reset loop for any barcode entered? How would you like the GUI to look? Would you like it to be compatible with NCR software? Can I have all rights when the program is complete? Lastly but most important: How much will the job pay? }
( end lost )
Tags: Barcode, basic, database, item, look, program, typing, Visual
Under Forum

1 Comment for Make a program in Visual Basic to look up item in database by typing UPC barcode?
1. Mark G | August 4th, 2010 at 6:47 am
I assume that you don’t mind using the CSV file as the database.
You open the file and read one line of text at a time and place it into a string variable.
Use the split command to parse (break apart) the CSV format data using the split function. Split will take a string and using a compare character will place the broken up data into an array
Look at the data in the array to see if it matches that UPC your looking for
If it matches then display the results (name)
Th efollowing code uses a button and a textbox to hold the UPC code you want to find. It assumes that your text file looks like
UPC, NAME
The code is barebones with no error detection or input validation.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dlg As New OpenFileDialog
Dim str, myFile, myData(), UPC, UPCname, UPCfind As String
Dim myReader As IO.StreamReader
With dlg
If .ShowDialog = Windows.Forms.DialogResult.Cancel Then
Exit Sub
Else
myFile = .FileName
End If
End With
‘
‘open the selected file
myReader = System.IO.File.OpenText(myFile)
‘
‘read the file one line at at time
While myReader.Peek >= 0
‘peek returns -1 when there is no more data in file to return
‘
‘read a line in the file
str = myReader.ReadLine
‘
‘break apart the CSV data line into individual fields
myData = Split(str, “,”)
‘transfer the data in the parsed array into named variables for easy ID
UPC = myData(0)
UPCname = myData(1)
UPCfind = TextBox1.Text
If UPC = UPCfind Then
MessageBox.Show(UPC & ” : ” & UPCname, “Found ” & UPC)
‘at this point there no further need to search teh rest of the file
Exit While
End If
End While
‘housekeeping:
myReader.Close() ‘close the CSV file
GC.Collect() ‘recover used memory
End Sub
End Class
Leave a Comment for Make a program in Visual Basic to look up item in database by typing UPC barcode?
Trackback this post | Subscribe to the comments via RSS Feed