INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Visual Basic (Microsoft) Versions 5/6 FAQ

Application/Utility Simulation

Implementing a TelnetApp. using Winsock control! by kaleatul
Posted: 28 Jun 01

Implementing a TelnetApp. using Winsock control!
A Preview

Assumptions...


sckTelnet -> WinSock control
sckTelnet.Protocal = sckTCPProtocal

timerTel -> Timer Control with Interval 500
------------------------------------------------------

Option Explicit
Dim X As Integer
------------------------------------------------------
Private Sub cmdConnect_Click()
    If Trim(txtRHostName.Text) = "" Or Trim(txtPortNo.Text) = "" Then
        MsgBox "Invalid Entry..."
    Else
        sckTelnet.RemoteHost = txtRHostName.Text
        sckTelnet.RemotePort = Val(txtPortNo.Text)
        sckTelnet.Connect
        timerTel.Enabled = True
        Frame1.Enabled = False
    End If
End Sub
------------------------------------------------------
Private Sub cmdSend_Click()
    sckTelnet.SendData txtCommand.Text + vbNewLine
    txtCommand.Text = ""
End Sub
------------------------------------------------------
Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = 27 Then
        Unload Me
    End If
End Sub
------------------------------------------------------
Private Sub Form_Load()
    Frame2.Enabled = False
    timerTel.Enabled = False
End Sub
------------------------------------------------------
Private Sub sckTelnet_DataArrival(ByVal bytesTotal As Long)
    Dim strData As String
    sckTelnet.GetData strData
    txtReply.Text = strData + vbNewLine
End Sub
------------------------------------------------------
Private Sub timerTel_Timer()
    X = X + 1
    If X > 20 Then
        MsgBox "Problem encountered connecting Host..."
        timerTel.Enabled = False
        Frame1.Enabled = True
        X = 0
        Label6.Caption = X
    End If
        
    If sckTelnet.State = 7 Then
        Frame2.Enabled = True
        Frame1.Enabled = False
        lblStatus.Caption = "Connected"
        timerTel.Enabled = False
        cmdSend.Default = True
    Else
        lblStatus.Caption = "State:" & sckTelnet.State
    End If

    Label6.Caption = X
End Sub
------------------------------------------------------



Back to Visual Basic (Microsoft) Versions 5/6 FAQ Index
Back to Visual Basic (Microsoft) Versions 5/6 Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close