Solved

Line by Line printing in VB.NEt

Posted on 2010-09-22
9
1,238 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 7

Expert Comment

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

http://support.microsoft.com/kb/823179
0
 

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:Alpha Au
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:
Alpha Au 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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Suggested Solutions

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 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