Solved

Line by Line printing in VB.NEt

Posted on 2010-09-22
9
1,121 Views
Last Modified: 2013-11-26
Hi
I have an application in VB6 that I am currently converting to VB.NET at work and we have a number of printers that work on a tractor feed due to the way we need to work.

Currently in the VB6 App when a part is processed the line printer will print a single line and wait for the next transaction, however we cannot get this to work the same in vb.net

The same code, simply will not work.  Does anyone have any ideas on how to sucessfully compelte this.

0
Comment
Question by:SimonPrice33
  • 5
  • 3
9 Comments
 
LVL 12

Expert Comment

by:jagssidurala
ID: 33735020
can you post your code please?
0
 

Author Comment

by:SimonPrice33
ID: 33735119
which, the .net or the vb6?
0
 

Author Comment

by:SimonPrice33
ID: 33735242
The top of the code section is the vb.net class that i have created in order to get it to complete a page print.

The code under the ----- is what calls the class

This allowd the pritner to complete a page print but its not what i need... I need a line print.


Public Class LinePrinter2

    Friend TextToBePrinted As String



    Public Sub Print(ByVal text As String)

        TextToBePrinted = text



        Dim prn As New Printing.PrintDocument



        Using (prn)

            'prn.PrinterSettings.PrinterName = "PrinterName"

            AddHandler prn.PrintPage, AddressOf Me.PrintPageHandler



            prn.Print()



            RemoveHandler prn.PrintPage, AddressOf Me.PrintPageHandler

        End Using

    End Sub



    Private Sub PrintPageHandler(ByVal sender As Object, _

       ByVal args As Printing.PrintPageEventArgs)



        Dim myFont As New Font("Microsoft San Serif", 10)



        args.Graphics.DrawString(TextToBePrinted, New Font(myFont, FontStyle.Regular), Brushes.Black, 50, 50)

    End Sub

End Class



----------------------------------------------------------------------------------------------------





            

PrintMsg = Prms.StationId & vbTab & DatePrn & vbTab & TimePrn & vbTab & Tran.Stub & vbTab & VB6.Format(Tran.Weight, "000") ' Print transaction





Dim lp As New LinePrinter2

            lp.Print(PrintMsg)

Open in new window

0
 
LVL 7

Expert Comment

by:alphaau
ID: 33751465
I am guessing do you need to access the com1 and print to it?

http://support.microsoft.com/kb/823179
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:SimonPrice33
ID: 33767728
the printer is a networked printer so I'm not sure if this will work
0
 
LVL 7

Expert Comment

by:alphaau
ID: 33767788
let's try on some custom class

http://www.codeproject.com/KB/dotnet/LPrintWriter.aspx

LPrintWriter lprint = new LPrintWriter();
lprint.WriteLine("Hello, world!");
lprint.Close();
0
 

Author Comment

by:SimonPrice33
ID: 33767809
looking at the code, it looks similar to one that we called and spits out a full page.
I will try it shortly and let you know if there are any issues
0
 
LVL 7

Accepted Solution

by:
alphaau earned 500 total points
ID: 33767941
and you might need to refer to this if the custom class don't work

How to send raw data to a printer by using Visual Basic .NET
http://support.microsoft.com/?scid=kb;EN-US;322090
0
 

Author Closing Comment

by:SimonPrice33
ID: 33769636
I had seen a very similar solution in C#.NET but i find C# hard to read (which is why i code in VB.NET...

Solution worked as i required after a few modifications.

many thanks

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now