Solved

Open Socket via VBA

Posted on 2013-01-28
3
4,526 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
  • 2
3 Comments
 
LVL 49

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 49

Expert Comment

by:Gustav Brock
ID: 38838600
You are welcome!

/gustav
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Even if you have implemented a Mobile Device Management solution company wide, it is a good idea to make sure you are taking into account all of the major risks to your electronic protected health information (ePHI).
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now