1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

problem with defineDosDevice

Discussion in 'Visual Basic ( VB )' started by nadunalexander, Jul 4, 2007.

  1. nadunalexander

    nadunalexander New Member

    Joined:
    Sep 13, 2006
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student
    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

    Code:
    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
    Printer.EndDoc
    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.
     
    Last edited by a moderator: Jul 4, 2007

Share This Page