Solved

Line by Line printing in VB.NEt

Posted on 2010-09-22
9
1,279 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

623 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