Remarque the hand punch is connected to the network throug a converter from serial to network , so i need to connect the port and the ip at the same time , any help ?

Dani AI

Generated

Quick practical plan (builds on 's interop idea and on 's notes): 1) determine how the serial->IP converter exposes the device (virtual COM port vs raw TCP/RFC2217), 2) determine what kind of DLL you have (COM/ActiveX vs native exports), 3) either talk to the converter directly from VB.NET or call the vendor DLL via COM interop or P/Invoke. Below are concrete checks, pitfalls, and short VB.NET examples to get you running.

To identify the DLL type and how to call it

  • Check exports: use Visual Studio's dumpbin /exports or Dependency Walker to see named exports (native) or a typelib/COM object.
  • If it is COM/ActiveX: register it (you may need admin rights; on 64-bit Windows register 32-bit COM with the 32-bit regsvr32), then Add Reference -> COM in Visual Studio or use late binding (CreateObject/Activator.CreateInstance).
  • If it is a native DLL: you must P/Invoke (<DllImport(...)>). Use the VB6 BAS modules you recovered to infer function names and parameter types. Important: VB6/legacy DLLs are usually 32-bit — set your VB.NET project platform to x86, otherwise the DLL will fail to load.

If the converter exposes plain TCP (common): use TcpClient/NetworkStream. If it installs a virtual COM driver, use SerialPort. Example raw-TCP client:

Imports System.Net.Sockets
Imports System.Text

Sub SendToConverter(ip As String, port As Integer, payload As Byte())
    Using tcp As New TcpClient()
        tcp.Connect(ip, port)
        Using ns = tcp.GetStream()
            ns.Write(payload, 0, payload.Length)
            ns.Flush()
            Dim buf(1023) As Byte
            Dim read = ns.Read(buf, 0, buf.Length)
            Dim resp = Encoding.ASCII.GetString(buf, 0, read)
        End Using
    End Using
End Sub

If the converter gives a COM port (example):

Dim sp As New IO.Ports.SerialPort("COM3", 9600, IO.Ports.Parity.None, 8, IO.Ports.StopBits.One)
sp.Open()
sp.WriteLine("your command")
Dim reply = sp.ReadExisting()
sp.Close()

Troubleshooting tips

  • Test reachability with a simple TCP client (telnet/PuTTY) to confirm IP/port and raw bytes.
  • Use Wireshark to capture TCP if protocol seems binary; compare what the existing VB6 exe sends (if you can capture it) and mirror that sequence.
  • Watch for required handshake bytes, CR/LF endings, baud/flow-control settings, and 32-bit vs 64-bit process issues.
    If vendor docs or an SDK exist, they save a lot of time; otherwise the steps above will let you either call the DLL or talk directly to the handpunch through the converter.

Recommended Answers

All 9 Replies

is a lengthy article on Serial/Parallel port programming in vb.net.

Have you contacted the equipment manufacturer to see if there is some API that you can use?

i have an api but its a vb6 application , i tried to decompile it , but unfortunately its a vb6 and BAS coding ... i want to develop a similar one throug vb.net

Does the application have non os libraries? For example: Something that was copied and registered when the application is installed?

the application has no installation wizard, its an exe file with a dll only

Try adding the Dll file to your project and use intuition to decalare some instances of the possible classnames inside. If the vendor has no documentation it will be extremely slow, but none the less, it could be a viable option.

If the application is written in VB6 you might have to work with interopt.

dunno what to do if you want i can give the exe file and the dll to check them

After a quick google session I found a piece of software that claims to expose the functions in a dll.

See if this might help you in any way.

Beware! I did not download this software or try it. It could be legit or could be scam.

thanks for your help

i want to write a vb.net to let me connect to my hand punch . my hand punch has serial port that are connected to converter that convert the serial port to network , that converter has an ip addreess , this converter is connected to my network , how i can wirte a code that can let me be connected to my handpunch throug this converter and get a fucntion form my dll ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.