Solved

App (VB6) hangs when close the port after try print to TM-U220

Posted on 2014-01-03
1
569 Views
Last Modified: 2014-01-08
I need open the cashdrawer conected to a Epson TM-U220 printer.
The code is ok and works.
But if the printer is unistalled, the app hangs when try to close the port

I need a procedure that detect if the printer is OK before run the Open_Cashdrawer procedure:


Private Sub Open_Cashdrawer()

On Error GoTo ErrorImpresionEPSON

Open "LPT2:" For Output As #1
 
             Print #1, Chr$(&H1B); "@"
 
             Print #1, Chr$(&H1B); Chr$(&H70); Chr$(&H0); Chr$(60); Chr$(120); 'Drawer Kick (ESC p)

Close #1 '<---- IF THE PRINTER DON'T EXIST, THE PROCEDURE HANG IN THIS POINT

Exit Sub
   
ErrorImpresionEPSON:
   
   Close #1
   MsgBox "Se Ha Producido un Error Al Imprimir" & vbCrLf & "Verifique La Conexión de la Impresora o Contacte con El Administrador del Sistema", vbCritical, ""

End Sub


Sorry for my english but I think the problem in clear.

Tanks
0
Comment
Question by:dperina
1 Comment
 
LVL 16

Accepted Solution

by:
HooKooDooKu earned 500 total points
ID: 39762890
If you just need to determine if the printer has been installed, you could iterate the printer collection and determine if there is a printer assigned to Port 'LPT2:'
Public Function LPT2Exists() as Boolean
Dim P as Printer
  For Each P in Printers
    If P.Port = "LPT2:" Then
        LPT2Exists = True
        Exit Function
    End If
  Next
  LPT2Exists = False

Open in new window

0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Iteration: Iteration is repetition of a process. A student who goes to school repeats the process of going to school everyday until graduation. We go to grocery store at least once or twice a month to buy products. We repeat this process every mont…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

763 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