Solved

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Article by: Nadia
Linear search (searching each index in an array one by one) works almost everywhere but it is not optimal in many cases. Let's assume, we have a book which has 42949672960 pages. We also have a table of contents. Now we want to read the content on p…
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…

751 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