📄 frmclient.frm
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form frmClient
Caption = "TCP Client"
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 5640
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 5640
StartUpPosition = 3 '窗口缺省
Begin MSWinsockLib.Winsock tcpClient
Left = 720
Top = 2400
_ExtentX = 741
_ExtentY = 741
_Version = 393216
End
Begin VB.TextBox txtOutput
Height = 495
Left = 1920
TabIndex = 2
Text = "Text1"
Top = 960
Width = 3375
End
Begin VB.TextBox txtSendData
Height = 495
Left = 1920
TabIndex = 1
Text = "Text1"
Top = 240
Width = 3375
End
Begin VB.CommandButton cmdConnect
Caption = "Connect"
Height = 615
Left = 3360
TabIndex = 0
Top = 2280
Width = 2055
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "接受的数据"
Height = 180
Left = 360
TabIndex = 4
Top = 1200
Width = 900
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "发送的数据"
Height = 180
Left = 240
TabIndex = 3
Top = 360
Width = 900
End
End
Attribute VB_Name = "frmClient"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
'Winsock 控件的名字为 tcpClient。
'注意:要指定远程主机,可以使用
' IP 地址(例如:"121.111.1.1"),也可以使用
'计算机的"好听的名字"如下所示。
tcpClient.RemoteHost = "localhost"
tcpClient.RemotePort = 1001
End Sub
Private Sub cmdConnect_Click()
'调用 Connect 方法,初始化连接。
tcpClient.Connect
End Sub
Private Sub txtSendData_Change()
tcpClient.SendData txtSendData.Text
End Sub
Private Sub tcpClient_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
tcpClient.GetData strData
txtOutput.Text = strData
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -