Solved

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

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
Article by: Nadia
Suppose you use Uber application as a rider and you request a ride to go from one place to another. Your driver just arrived at the parking lot of your place. The only thing you know about the ride is the license plate number. How do you find your U…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

758 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

22 Experts available now in Live!

Get 1:1 Help Now