Solved

Open Socket via VBA

Posted on 2013-01-28
3
5,167 Views
Last Modified: 2013-01-30
Here's some code in VB.NET:

Dim port As Int32 = 9200
            Dim client As System.Net.Sockets.TcpClient = New System.Net.Sockets.TcpClient(server, port)
            Dim netStream As System.Net.Sockets.NetworkStream = client.GetStream()
            Dim charData As Char() = New Char() {}
            ReDim charData(data.Length)
            ' Translate the passed message into ASCII
            'Dim sb As StringBuilder = New StringBuilder()

            For i As Integer = 0 To data.Length - 1
                charData(i) = ChrW(data(i))
                'sb.Append(charData(i).ToString())
            Next
            'sb.Append("")
            data = System.Text.Encoding.ASCII.GetBytes(charData)
            netStream.Write(data, 0, data.Length)
            ' Close everything.
            netStream.Close()

Open in new window


I need similar functionality from within MS Access / VBA.

Essentially, I need to open a socket and send some data through it, then close the socket.

I'm trying to avoide 3rd party (paid) tools, if possible.

Thanks for your help.
0
Comment
Question by:Kaprice
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 51

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 38830453
Here's an article describing how to use the WinSock control:

Create a Syslog Sender/Receiver Using the MS Winsock Control

The ActiveX control can be a bit hard to locate but that is explained as well.

/gustav
0
 

Author Closing Comment

by:Kaprice
ID: 38838542
Thanks. That's a good article.
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 38838600
You are welcome!

/gustav
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question