One of my client is facing this issue that the vb6 exe is crashing every time he tries to print the message text from the print button present in the exe.
Following is the code written for print button.
iRetValue = GetProfileString("windows", "device", ",,,", strBuffer, 254)
strDefaultPrinterInfo = Left(strBuffer, InStr(strBuffer, Chr(0)) -
tblDefaultPrinterInfo = Split(strDefaultPrinterInfo, ",")
Dim picount As Integer
picount = 0
For Each objPrinter In Printers
picount = picount + 1
If objPrinter.DeviceName = tblDefaultPrinterInfo(0) Then
' Default printer found !
Exit For
End If
Next
If objPrinter.DeviceName <> tblDefaultPrinterInfo(0) Then
Set objPrinter = Nothing
GoTo ExitHandler
End If
Set GetDefaultPrinter = objPrinter
txtPrintMsg.text = txtMsg.text
txtPrintMsg.SelPrint objPrinter.hDC
Total printers they have are 700.