[RESOLVED] Saving a file on a scanner (VB2005)
I have a Symbol MC9090 barcode scanner. I have figured out how to get the scanner part working. It now displays the data in the proper text boxes on the screen.
Now, when the user pushes a command button, I need to write data to a file and store it on the scanner. The file will be downloaded to a pc at the end of the user's shift.
Anybody have any sample code or can direct me to where I might find some?
Re: Saving a file on a scanner (VB2005)
Hi,
search the forum for 'streamwriter', or check it in the help file. There is sample code showing how to write to a text file
Pete
Re: Saving a file on a scanner (VB2005)
Thanks for your input. However, I was hoping for something a bit more specific to the barcode scanner. For instance, It does not like me using "My.Application..." that really throws any samples I can find out the window.
Re: Saving a file on a scanner (VB2005)
Hi,
sorry - is writing to the file not what you wanted, i.e.
Code:
Dim sw As StreamWriter
sw = File.CreateText(DataPath & "myfile.txt")
sw.WriteLine(textbox1.Text)
sw.Flush()
sw.Close()
I don't understand where 'My.Application' comes into it?
Pete
Re: Saving a file on a scanner (VB2005)
Right away it tells me that StreamWriter is not defined....
Re: Saving a file on a scanner (VB2005)
Hi,
or do
Code:
system.io.streamwriter
Re: Saving a file on a scanner (VB2005)
I figured that one out. Now I have a new issue. This is my code, at the moment:
'-- Process data
Dim csvfile As String = "%CSIDL_PROGRAM_FILES%\Technigraph"
Dim outFile As StreamWriter
outFile = File.CreateText(csvfile & "\Test.csv")
'-- Build the output file
outfile.writeline("XXX", Format(Now, "mm/dd/yyyy"), Format(Now, "hh:mm"), "T", TextBox1.Text, TextBox2.Text, TextBox3.Text)
outFile.flush()
outFile.close()
It appears to be having trouble creating the file. It says it can't find "\%CSIDL_PROGRAM_FILES%\Technigraph\Test.csv"
I don't understand why it is putting the "\" in the front of it. I copied the '%CSIDL_PROGRAM_FILES%\" from a sample application. the "\Technigrph" is the folder that the application resides in.
Re: Saving a file on a scanner (VB2005)
And the first time it is accessed, it won't be there.... you should check to see if the .folderExists first, if not, create it...THEN write to your file.
-tg
Re: Saving a file on a scanner (VB2005)
I thought this line created it...
outFile = File.CreateText(csvfile & "\Test.csv")
Re: Saving a file on a scanner (VB2005)
Hi,
%CSIDL_PROGRAM_FILES% is not valid - where did you get that from?
\Program Files\Technigraph would be your valid path
Pete
Re: Saving a file on a scanner (VB2005)
That did it. It only got the first "field", but I can work that out tomorrow. Thanks for the help.