Solved

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

Posted on 2014-01-03
1
563 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

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

Okay. So what exactly is the problem here? How often have we come across situations where we need to know if two strings are 'similar' but not necessarily the same? I have, plenty of times. Until recently, I thought any functionality like that wo…
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…
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…

920 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

16 Experts available now in Live!

Get 1:1 Help Now