Solved

Open Socket via VBA

Posted on 2013-01-28
3
4,756 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
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.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…

785 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