How to Interface Telnet With VB6
Telnet is a network protocol used over the Internet that allows communication between computers. Telnet provides access to a command interface and is often used to execute commands and manage remote computers. Visual Basic 6, or VB6, is a programming language developed by Microsoft that can be used to create and interface with Telnet. Creating a program that makes use of Telnet in VB6 requires an understanding of Telnet and VB6 programming.
Instructions
-
-
1
Open Visual Basic 6.
-
2
Select "Standard EXE" from the new project list. You should have a default main form on your screen to start adding your controls.
-
-
3
Click "Project, and then click "References." Scroll down, and select the "ActiveSocket 3.1" control from the list.
-
4
Double-click on the main form to get into its Form_Load event.
-
5
Copy and paste the following code block into the Form's code module:
Option Explicit
Dim objSocket As ASOCKETLib.Tcp
Private Sub BTN_Connect_Click()
objSocket.Connect TXT_Host, 23
TXT_Result = "CONNECT: " & objSocket.LastError & " (" & objSocket.GetErrorDescription(objSocket.LastError) & ")"
End Sub
Private Sub BTN_Disconnect_Click()
objSocket.Disconnect
TXT_Result = "DISCONNECT: " & objSocket.LastError & " (" & objSocket.GetErrorDescription(objSocket.LastError) & ")"
End Sub
Private Sub BTN_Submit_Click()
objSocket.SendString TXT_Command
TXT_Result = "SEND: " & objSocket.LastError & " (" & objSocket.GetErrorDescription(objSocket.LastError) & ")"
End Sub
Private Sub Form_Load()
Set objSocket = CreateObject("ActiveXperts.Tcp")
objSocket.Protocol = objSocket.asPROTOCOL_TELNET
TXT_Result = "N/A"
TXT_Received = ""
End Sub
Private Sub Timer_Timer()
While objSocket.HasData
TXT_Received.Text = TXT_Received & objSocket.ReceiveString
Wend
End Sub
-
1