Excel Vba Serial Port Mscomm32

Excel Vba Serial Port Mscomm32 Rating: 4,5/5 6340 votes

Recently, I got helpful advice on how to install and register MSComm32.ocx for a serial communication project I am working on. I have succeeded in getting it on my home Windows XP machine where I write code, and a PC at work running Win' 98. The work PC is actually hooked up to the serial device, a pump controller. Since then, I have established communication with the controller using Hyperterminal. The controller has its own serial protocol using ASCII characters.

Bridged to a COM16 serial port. According to the vendor I just need to send char(27)+char(53) down the serial port andit will open the cash drawer. They provide a MS Excel VBA sample which uses MScomm32.ocx and it works. But I have difficulties using that ocx file in PB 8. Is there someone here who can give me the required steps to implement.

Commands from the PC begin with a 'start of text' character and end with a 'carriage return'. The controller responds with data, followed. The body of PC transmissions may have 1- or 2-letter commands, sometimes followed by numeric parameters. The controller resonds with an 'acknowledge' symbol, a 'negative acknowledge' symbol, or numeric data. Now that I am familiar with the controller protocol, I'm moving on to VBA code. Glitter bot seafight czateria cheats. I'm slowly working through a site,, a number of MicroSoft Knowledge Base articles, and code samples provided by Expert Exchange members, to get started writing actual subroutines. Perhaps someone can help me 'jump start' this part of the project with some simple code samples?

For example, I'd like to ask the controller what setup program is assigned to pump drive 1, 'N1 and display the numeric response from the controller, '#', with the carriage return removed. I envision starting with something like, Private Sub Form_Load( ) With MSComm1.Settings = '9600,O,7,2' 'baud,parity,data bits,stop bits.CommPort = 1.PortOpen = True End With although I've also seen statements like, Open 'COM1:9600,n,7,2' For Input as #1 Is this equivalent to the previous 'With' statement? Also, the protocol says the use of handshaking when communicating with the controller is optional. Should I ignore the Handshaking property, or set it to something? A little advice, up front, should help me get this coding started. Osmodean, Thank you for your encouragement, but I still need an answer to my questions. Perhaps I should focus and even expand a little.

Are the use of MSComm and the Open Comm statement equivalent? How does the Comm statement work? What would a sample subroutine using the Comm statement look like? How does one decide whether to use Xon/Xoff, RTS/CTS, or both for handshaking? What is the default for the Handshaking property of the MSComm control? How do I actually send strings, adding ASCII characters like and (shown above)?

How would I capture a character string, strip extra characters, and display it (would a message box or text box work best)? Some more specific discussion along these lines would be quite helpful. I need more specific advice.

I have bought Visual Basic.NET Standard Edition. Version 6 is no longer available at my local computer store. I have also installed an extra serial port in my CPU, to allow me to test transmissions and receptions. I had hoped that the available MSComm code for V5 and V6 could be more readily translated to.NET code. I am learning about differences between the various versions. Ideally, I'd like to get started with something that will work 'out of the box' for Excel VBA. Then I could use that as a basis to build upon.

Alternatively, code for VB.NET would be helpful. I've found a Knowledge Base article on using MSComm with VB.NET, so I'm working slowly through that. I'm also digesting the references given above. Zhivotnij mir lesov belarusi prezentaciya.