Solved

Line by Line printing in VB.NEt

Posted on 2010-09-22
9
1,153 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

937 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

9 Experts available now in Live!

Get 1:1 Help Now