Results 1 to 7 of 7

Thread: Printing files for dummies :)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Location
    St-Élie d'Orford, Quebec, Canada
    Posts
    133
    God I hate to admit it but I don't know how to print files in VB !

    I use the common dialog to set everything the user wants but I don't find anything to launch the printing sequence...

    Please feel sorry for me not knowing this and help me out
    :-)

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Do something like this:
    Code:
    Printer.Print "Hello World! :-)"
    Printer.EndDoc
    Oetje
    oetje@home.nl
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  3. #3
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    *Vince

    It really depends on what you want to print:

    I use VB Printer.print alot. This allow you to place data on a a page using x, y coordinates which, does ttake more time, but for me, it's not a problem.

    People have suggested buying Crystal Reports or other 3rd Party, but, right now, b's Printer.print does the job for me.

    You can use a for loop to print multiple pages, too.

    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  4. #4
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    The Printer object works just like a picture box. It also has property's like CurrentX and CurrentY.
    Oetje
    oetje@home.nl
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Location
    St-Élie d'Orford, Quebec, Canada
    Posts
    133
    Thanks guys but I don't want to open the file and read it all to send it to the printer, I want to send the file to the printer that's it ! Is there a way to do so ?

  6. #6
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    No, but you can do it in code like this:
    Code:
    'read the file line by line and sent the output
    'to the printer
    Dim oneLine As String 'one line in the file
    
    'open the file
    Open "C:\Myfile.txt" For Input As #1
    
    'loop through all the lines
    Do
        'read a line
        Line Input #1,oneLine
        'print the line
        Printer.Print oneLine
    Loop Until Eof(1)
    
    'say that the printing has ended
    Printer.EndDoc
    
    'close the file
    Close #1
    Oetje
    oetje@home.nl
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  7. #7
    Member
    Join Date
    Oct 2000
    Location
    Philadelphia
    Posts
    47

    try using office

    If you have office on your machine, and the file is not strickly a test file, i would try using a word object... send the information you want to word and then use that to print it out... its nice becase you can also use it for print previews and jazz like that... just a suggestion.
    U S A
    Visual Studio .NET
    Windows XP

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