Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-01-03
1
Medium Priority
?
609 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 2000 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…

926 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