📄 frmclient.frm
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form frmClient
BorderStyle = 1 'Fixed Single
Caption = "TCP客户端"
ClientHeight = 2610
ClientLeft = 45
ClientTop = 330
ClientWidth = 7455
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2610
ScaleMode = 0 'User
ScaleWidth = 7573.333
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox txtOutput
Height = 1140
Left = 120
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 7
Top = 840
Width = 7215
End
Begin VB.TextBox txtHost
Height = 300
Left = 2880
TabIndex = 1
Top = 120
Width = 1935
End
Begin VB.CommandButton comdSendData
Caption = "发送"
Height = 300
Left = 6120
TabIndex = 4
Top = 2160
Width = 1215
End
Begin VB.CommandButton cmdConnect
Caption = "连接服务器"
Height = 300
Left = 120
TabIndex = 0
Top = 120
Width = 1575
End
Begin MSWinsockLib.Winsock tcpClient
Left = 6480
Top = 120
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemoteHost = "IBMCSMY"
End
Begin VB.TextBox txtSendData
Height = 300
Left = 960
TabIndex = 3
Top = 2160
Width = 5055
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "服务器:"
Height = 180
Left = 2160
TabIndex = 6
Top = 120
Width = 630
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "接收数据:"
Height = 180
Left = 120
TabIndex = 5
Top = 600
Width = 810
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "传送数据:"
Height = 180
Left = 120
TabIndex = 2
Top = 2160
Width = 810
End
End
Attribute VB_Name = "frmClient"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdConnect_Click()
If tcpClient.State <> sckClosed Then
tcpClient.Close '关闭服务器连接
End If
tcpClient.RemoteHost = Trim(txtHost) '设置远程主机
tcpClient.Connect '连接新的服务器
End Sub
Private Sub comdSendData_Click()
'向远程计算机发送数据
On Error GoTo ErrBar
tcpClient.SendData txtSendData
Exit Sub
ErrBar:
MsgBox Error & Space(2) & Err
End Sub
Private Sub Form_Load()
tcpClient.RemotePort = 1001 '设置远程端口
End Sub
Private Sub tcpClient_DataArrival(ByVal bytesTotal As Long)
'接收远程计算机传送的数据
Dim strData As String
tcpClient.GetData strData
txtOutput = txtOutput & Chr(13) & Chr(10) & strData
txtOutput.SelStart = Len(txtOutput)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -