📄 客户端1.frm
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3105
ClientLeft = 60
ClientTop = 435
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3105
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.Timer Timer1
Interval = 1000
Left = 1680
Top = 720
End
Begin VB.TextBox txtSend
Height = 975
Left = 240
MultiLine = -1 'True
TabIndex = 3
Top = 2040
Width = 1695
End
Begin VB.TextBox Text1
Height = 2895
Left = 2160
MultiLine = -1 'True
TabIndex = 2
Top = 120
Width = 2295
End
Begin VB.CommandButton Command2
Caption = "发送"
Height = 375
Left = 240
TabIndex = 1
Top = 1440
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "连接"
Height = 375
Left = 240
TabIndex = 0
Top = 720
Width = 1095
End
Begin MSWinsockLib.Winsock sock
Left = 960
Top = 120
_ExtentX = 741
_ExtentY = 741
_Version = 393216
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
If sock.State <> 0 Then
Exit Sub
Else
sock.Connect
End If
End Sub
Private Sub Command2_Click()
'+++++++++++++++++++++++++++++++++
'以下内容2008年11月23日9:20:47添加
'功能时读取目录下的一个XML文件,发送出去
'+++++++++++++++++++++++++++++++++
Dim FileNum As Long
Dim Data As String
Dim OneText As Boolean
OneText = False
FileNum = FreeFile
Open App.Path & "\initfile.xml" For Input As FileNum
Do While Not EOF(FileNum) '循环,只到文件结束
Line Input #FileNum, Data '将文件中的一行读到data 中
If OneText = 0 Then
txtSend.Text = Data
OneText = 1
Else
txtSend.Text = txtSend.Text & Chr(13) & Chr(10) & Data
End If
Loop
sock.SendData txtSend.Text
End Sub
Private Sub Form_Load()
sock.RemoteHost = "218.192.172.27"
sock.RemotePort = 4242
End Sub
Private Sub sock_DataArrival(ByVal bytesTotal As Long)
Dim c As String
sock.GetData c, vbString
Text1.Text = Text1.Text & c & vbCrLf
End Sub
Private Sub Timer1_Timer()
Debug.Print sock.State
If sock.State = 8 Then
sock.Close
Text1.Text = Text1.Text + "服务器关闭" & vbCrLf
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -