|
-
Aug 27th, 2007, 11:20 AM
#1
Thread Starter
PowerPoster
[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?
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Aug 27th, 2007, 11:32 AM
#2
Frenzied Member
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
-
Aug 27th, 2007, 12:00 PM
#3
Thread Starter
PowerPoster
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.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Aug 27th, 2007, 12:38 PM
#4
Frenzied Member
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
-
Aug 27th, 2007, 01:21 PM
#5
Thread Starter
PowerPoster
Re: Saving a file on a scanner (VB2005)
Right away it tells me that StreamWriter is not defined....
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Aug 27th, 2007, 01:54 PM
#6
Frenzied Member
Re: Saving a file on a scanner (VB2005)
Hi,
or do
Code:
system.io.streamwriter
-
Aug 27th, 2007, 02:30 PM
#7
Thread Starter
PowerPoster
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.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Aug 27th, 2007, 02:37 PM
#8
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
-
Aug 27th, 2007, 02:40 PM
#9
Thread Starter
PowerPoster
Re: Saving a file on a scanner (VB2005)
I thought this line created it...
outFile = File.CreateText(csvfile & "\Test.csv")
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Aug 27th, 2007, 02:46 PM
#10
Frenzied Member
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
-
Aug 27th, 2007, 02:52 PM
#11
Thread Starter
PowerPoster
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.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|