none
How do I print text from a text file in visual basic?

    Question

  • I've been trying to print out a text string to a printer that I have connected. I cannot print using the PrintDocument.Print() as this sends the string as a graphic to the printer. I don't know C# and I am very new to full fledged VB having spent most of my time using VBA in Excel.

    Ideally I would like to know how to take a string that I created and send it to a printer as text. I know it sounds simple, but I haven't found any clear explanations of how to go about this task. Any help is appreciated!!

     

    PhilC

    Friday, October 22, 2010 11:21 PM

Answers

  • Thanks, there actually is a VB.NET version of that article:

    http://support.microsoft.com/kb/322090

    One of the hazards of following so many forums is that I just saw C# in the first paragraph of the question and didn't notice what forum this was :)

    But good link on the converter tool.  That one can be very useful and good to know.

     

    • Marked as answer by DocSpoon Monday, October 25, 2010 8:47 PM
    Saturday, October 23, 2010 2:38 PM

All replies

  • The following might be what you are asking for.  No, it's not really simple because most people printing on Windows want to use the nice fonts that Windows supports instead of dealing with the printer directly.

    How to send raw data to a printer by using Visual C# .NET

    http://support.microsoft.com/kb/322091

     

    Saturday, October 23, 2010 12:29 AM
  • Use http://www.developerfusion.com/tools/convert/csharp-to-vb/ to convert C# to VB .NET

    Striving to do my best.
    Saturday, October 23, 2010 1:35 AM
  • Thanks, there actually is a VB.NET version of that article:

    http://support.microsoft.com/kb/322090

    One of the hazards of following so many forums is that I just saw C# in the first paragraph of the question and didn't notice what forum this was :)

    But good link on the converter tool.  That one can be very useful and good to know.

     

    • Marked as answer by DocSpoon Monday, October 25, 2010 8:47 PM
    Saturday, October 23, 2010 2:38 PM
  • Hi,

    This sample application demonstrates how to print text and configure the printer.

    http://msdn.microsoft.com/en-us/library/54z247f9(v=VS.80).aspx

    regards Ellen

    Remarks: This is the code to load a text file into a RichTextbox

     RichTextBox1.LoadFile("D:\daten.txt", RichTextBoxStreamType.PlainText)
    
    to run this powerfull sample .....



    Ich benutze/ I'm using VB2008 & VB2010
    • Edited by Ellen Ramcke Saturday, October 23, 2010 9:09 PM remark
    Saturday, October 23, 2010 8:58 PM
  • Ellen:

    Your post is totally off-topic for this thread.  The OP wants to send raw text to a printer.

    Saturday, October 23, 2010 10:33 PM
  • Thanks for the attempt but this example again uses the graphics printing that I cannot use. I do appreciate the attempt and I did consider this method before I posted my question.

     

    DocSpoon

    Monday, October 25, 2010 8:44 PM
  • Awesome, Thank you so much. This will help me understand the methods/ syntax for accessing printers and printing. I'll let you know if this does indeed solve my issue, but I'm confident that it will.

     

    Thank you!

     

    DocSpoon

     

    Monday, October 25, 2010 8:46 PM
  • Thank you so much!! This will help me figure out some of the more advanced functions, wspecially when the examples are only in C#!!

    DocSpoon

    Monday, October 25, 2010 8:48 PM
  • Thanks, there actually is a VB.NET version of that article:

    http://support.microsoft.com/kb/322090

    One of the hazards of following so many forums is that I just saw C# in the first paragraph of the question and didn't notice what forum this was :)

    But good link on the converter tool.  That one can be very useful and good to know.

     

    HI BC,

     

    I just wanted to pop in and let you know that that code worked perfectly. I can now finish my barcode program and compile it for distribution. FYI this question is really about a month and a half old as I asked this question on various forums and sites and you are the first to answer the question. Thank you Very Much!!

     

    Doc

    Tuesday, October 26, 2010 8:25 PM
  • Glad you got it working!  Congrats!

     

    Tuesday, October 26, 2010 11:08 PM