Results 1 to 11 of 11

Thread: [RESOLVED] Saving a file on a scanner (VB2005)

  1. #1

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Resolved [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]

  2. #2
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    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
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  3. #3

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    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]

  4. #4
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    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
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  5. #5

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    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]

  6. #6
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Saving a file on a scanner (VB2005)

    Hi,
    Code:
    imports system.io
    or do
    Code:
    system.io.streamwriter
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  7. #7

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    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]

  8. #8
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    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]

  10. #10
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    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
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  11. #11

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    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
  •  



Click Here to Expand Forum to Full Width