Form1.frm
上传用户:gainingqun
上传日期:2015-05-26
资源大小:2k
文件大小:4k
源码类别:

Telnet客户端

开发平台:

Visual Basic

  1. VERSION 5.00
  2. Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
  3. Begin VB.Form Form1 
  4.    Caption         =   "Form1"
  5.    ClientHeight    =   5610
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   5130
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   5610
  11.    ScaleWidth      =   5130
  12.    StartUpPosition =   3  '窗口缺省
  13.    Begin MSWinsockLib.Winsock Winsock1 
  14.       Left            =   2160
  15.       Top             =   5280
  16.       _ExtentX        =   741
  17.       _ExtentY        =   741
  18.       _Version        =   393216
  19.    End
  20.    Begin VB.Frame Frame1 
  21.       Height          =   1215
  22.       Left            =   120
  23.       TabIndex        =   2
  24.       Top             =   120
  25.       Width           =   4935
  26.       Begin VB.CommandButton Command1 
  27.          Caption         =   "连接"
  28.          Height          =   855
  29.          Left            =   3360
  30.          TabIndex        =   7
  31.          Top             =   240
  32.          Width           =   1095
  33.       End
  34.       Begin VB.TextBox Text4 
  35.          Height          =   375
  36.          Left            =   1080
  37.          TabIndex        =   4
  38.          Text            =   "Text4"
  39.          Top             =   720
  40.          Width           =   1935
  41.       End
  42.       Begin VB.TextBox Text3 
  43.          Height          =   375
  44.          Left            =   1080
  45.          TabIndex        =   3
  46.          Text            =   "Text3"
  47.          Top             =   240
  48.          Width           =   1935
  49.       End
  50.       Begin VB.Label Label2 
  51.          AutoSize        =   -1  'True
  52.          Caption         =   "端口:"
  53.          Height          =   180
  54.          Left            =   360
  55.          TabIndex        =   6
  56.          Top             =   720
  57.          Width           =   540
  58.       End
  59.       Begin VB.Label Label1 
  60.          AutoSize        =   -1  'True
  61.          Caption         =   "服务器:"
  62.          Height          =   180
  63.          Left            =   240
  64.          TabIndex        =   5
  65.          Top             =   360
  66.          Width           =   720
  67.       End
  68.    End
  69.    Begin VB.TextBox Text2 
  70.       Height          =   375
  71.       Left            =   0
  72.       TabIndex        =   1
  73.       Top             =   4800
  74.       Width           =   5055
  75.    End
  76.    Begin VB.TextBox Text1 
  77.       BackColor       =   &H80000007&
  78.       ForeColor       =   &H80000005&
  79.       Height          =   3255
  80.       Left            =   120
  81.       MultiLine       =   -1  'True
  82.       ScrollBars      =   2  'Vertical
  83.       TabIndex        =   0
  84.       Top             =   1440
  85.       Width           =   4935
  86.    End
  87. End
  88. Attribute VB_Name = "Form1"
  89. Attribute VB_GlobalNameSpace = False
  90. Attribute VB_Creatable = False
  91. Attribute VB_PredeclaredId = True
  92. Attribute VB_Exposed = False
  93. Private Sub Command1_Click()
  94. On Error GoTo 1
  95. Form1.Winsock1.Close
  96. Form1.Winsock1.Connect Text3.Text, Text4.Text
  97. SaveSetting "Telnetclient", "Last", "Server", Text1.Text
  98. SaveSetting "Telnetclient", "Last", "Port", Text2.Text
  99. Exit Sub
  100. 1 MsgBox Err.Description, vbCritical
  101. Form1.Winsock1.Close
  102. End Sub
  103. Private Sub Form_Load()
  104. a = GetSetting("Telnetclient", "Last", "Server", "")
  105. If a = "" Then
  106. Else
  107. End If
  108. Text3.Text = GetSetting("Telnetclient", "Last", "Server", "")
  109. Text4.Text = GetSetting("Telnetclient", "Last", "Port", 23)
  110. End Sub
  111. Private Sub Text1_Change()
  112. Text1.SelStart = Len(Text1.Text)
  113. Text2.SetFocus
  114. End Sub
  115. Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
  116. KeyCode = 0
  117. End Sub
  118. Private Sub Text2_KeyPress(KeyAscii As Integer)
  119. On Error GoTo 1
  120. If KeyAscii = 13 Then
  121. Text2.Text = ""
  122. Winsock1.SendData Chr(13)
  123. KeyAscii = 0
  124. Else
  125. Winsock1.SendData Chr(KeyAscii)
  126. End If
  127. Exit Sub
  128. 1 KeyAscii = 0
  129. End Sub
  130. Private Sub Winsock1_Close()
  131. MsgBox "断开连接!"
  132. Winsock1.Close
  133. End Sub
  134. Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
  135. Winsock1.GetData buffer$, vbString
  136. Text1.Text = Text1.Text & buffer$
  137. End Sub