|
I have to communicate to a stepper motor controller and I'm using VB 2008 Express. I had thought the interface was going to be USB but the one that showed up has an ethernet interface. I have done some research and found that Winsock is not really used any more for this, with the TCPClient class in System.Net.Sockets being preferred. The example from the stepper OEM uses an outdated Winsock type of dll. Most of my experience is in VB6 and VBA, so can anyone give advice or sample code that would point me in the right direction on how to use TCPClient. Is it better to create a separate class or use it in a module? The functionality is to send short ascii commands to an IP address/port and receive back short ascii responses. I have a working program otherwise that also does serial comms and just need to get this going. Thanks. |
|
VB6 and VBA are quite different from VB.Net as far as organization goes. There are no 'modules' per say, so you'll need to use a separate class. The example that Scott provided is a good start, but there are some optimizations that can be made:
note: this is a quick adaptation from my own code base, so this is in C# and may contain a few typos VB Usage:
C# Usage:
If your looking for input on Visual Basic, C#, or pretty much any other programming language outside the scope of ladder logic and function blocks, I'd try my luck on Stackoverflow.com first. |


