Solved

Howto do simple TCP/IP programming using VBA

Posted on 2000-03-03
7
5,724 Views
Last Modified: 2013-11-13
can I do some simple TCP/IP programming using VBA ?  I guess I should be able to do that since I can call DLLs.  Can some one show some simple example ?  What I want to do is open a very simple telnet session, send some strings over, then receive the response, then close the connection.  Any one know how to call those WinSock APIs?  Thanks
0
Comment
Question by:c722
  • 3
  • 2
  • 2
7 Comments
 
LVL 1

Expert Comment

by:pookytoo
ID: 2579352
The easiest way will be to use a ocx to do everything for you. You can find a sample at:
http://support.microsoft.com/support/kb/articles/Q185/7/26.ASP?LNG=ENG&SA=ALLKB&FR=0

The sample is created in VB, but it should be no problem to use it's code in Access modules and forms.
0
 

Author Comment

by:c722
ID: 2579449
Thanks. I just checked the code.  I'm afraid I can't use that.  I need complete control of the sockets in the low level, i.e., like calling connect(), send() BSD style functions.  I'm doing something very simple so not afford to use ocx.
0
 
LVL 1

Accepted Solution

by:
pookytoo earned 200 total points
ID: 2579547
There is a sample that shows it at http://tcfreenet.org/people/parity/winsock.htm
It contains a module that has all the functions declared that you'll need. Maybe worth looking at.....
0
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 3

Expert Comment

by:ivanc
ID: 2579835
c722

Here is a sample, I hope it is helpful

Private Sub Form_Load()
' The name of the Winsock control is tcpClient.
' Note: to specify a remote host, you can use
' either the IP address (ex: "121.111.1.1") or
' the computer's "friendly" name, as shown here.
tcpClient.RemoteHost = "137.132.160.240"
tcpClient.RemotePort = 1001
tcpClient.Connect
End Sub

Private Sub tcpClient_DataArrival _
(ByVal bytesTotal As Long)
Dim strData As String
Dim n As Integer
tcpClient.GetData strData
txtoutput.text = strData
End Sub

Private Sub Form_Unload()
tcpClient.Close
Unload Me
End Sub

This codes are for the client

Ivanc
0
 

Author Comment

by:c722
ID: 2580325
this is what I'm looking for!  I did BSD socket programming in C before.  So I just need a quick way to call them in Basic, a language I'm not familiar with.  Thanks

I wanted to share the points with another writer....see can do it or not...
0
 

Author Comment

by:c722
ID: 2580334
sorry ivanc  I cannot split the points...
0
 
LVL 3

Expert Comment

by:ivanc
ID: 2580906
c722

Don't mind glad that your program is working.

Ivanc
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

830 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