Solved

Howto do simple TCP/IP programming using VBA

Posted on 2000-03-03
7
5,524 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

770 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