Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   problem with defineDosDevice (http://www.go4expert.com/forums/problem-with-definedosdevice-t5101/)

nadunalexander 4Jul2007 12:19

problem with defineDosDevice
I am working with a pos printer and customer display. My computer have only one com port com1. So I coudnt connect both directly to my computer, fortunately the customer display has a RS232 connector for my printer and by passing option to send data.
After I installed the printer driver. I coudnt use MScomm control to send data to customer display. After that I create a virtual comm port com5 and send data to customer display by following code.

The form contain a comm control , name=MScomm1, CommPort=5


Public Sub disInCusDis(disStr As String)
  DefineDosDevice DDD_RAW_TARGET_PATH, "COM5", "\Device\Serial0"
  'defining a virtual com port with name com5
'the reason is that i coudnt open com1.Because the driver took that

MSComm1.PortOpen = True

MSComm1.Output = Chr(27) + "=" + Chr(2)  'for display, dont mesh up
                                                                  ' with this .this is not  vb

MSComm1.Output = Chr(27) & "@" ' To clear display
MSComm1.Output = disStr
MSComm1.Output = Chr(27) + "=" + Chr(1) 'to bypass customer dis

MSComm1.PortOpen = False

DefineDosDevice DDD_RAW_TARGET_PATH, "COM1", "\Device\Serial0"
'now driver has com1 port

End Sub

Public Sub printByPosPrint(prntStr As String)
Printer.Print  prntStr
end sub

now both are working. But when the application run sub disInCusDis(). The printer print earliar lines. When I using again and again, the all the lines are print again again with my current printing
How can I stop?
I think that when i redefine the "\Device\Serial0" The windows lost the control and send all the data that has.
If any one have any idea pls tell me.

All times are GMT +5.5. The time now is 15:56.