📄 form1.frm
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 4995
ClientLeft = 60
ClientTop = 345
ClientWidth = 7605
LinkTopic = "Form1"
ScaleHeight = 4995
ScaleWidth = 7605
StartUpPosition = 3 'Windows Default
Begin VB.TextBox Text3
Height = 375
Index = 7
Left = 3360
TabIndex = 27
Text = "Text3"
Top = 4440
Width = 735
End
Begin VB.TextBox Text3
Height = 375
Index = 6
Left = 3360
TabIndex = 26
Text = "Text3"
Top = 3960
Width = 735
End
Begin VB.TextBox Text3
Height = 375
Index = 5
Left = 3360
TabIndex = 25
Text = "Text3"
Top = 3480
Width = 735
End
Begin VB.TextBox Text3
Height = 375
Index = 4
Left = 3360
TabIndex = 24
Text = "Text3"
Top = 3000
Width = 735
End
Begin VB.TextBox Text3
Height = 375
Index = 3
Left = 3360
TabIndex = 23
Text = "Text3"
Top = 2520
Width = 735
End
Begin VB.TextBox Text3
Height = 375
Index = 2
Left = 3360
TabIndex = 22
Text = "Text3"
Top = 2040
Width = 735
End
Begin VB.TextBox Text3
Height = 375
Index = 1
Left = 3360
TabIndex = 21
Text = "Text3"
Top = 1560
Width = 735
End
Begin VB.TextBox Text3
Height = 375
Index = 0
Left = 3360
TabIndex = 20
Text = "Text3"
Top = 1080
Width = 735
End
Begin VB.TextBox Text2
Height = 375
Index = 7
Left = 2400
TabIndex = 19
Text = "0"
Top = 4440
Width = 855
End
Begin VB.TextBox Text2
Height = 375
Index = 6
Left = 2400
TabIndex = 18
Text = "0"
Top = 3960
Width = 855
End
Begin VB.TextBox Text2
Height = 375
Index = 5
Left = 2400
TabIndex = 17
Text = "0"
Top = 3480
Width = 855
End
Begin VB.TextBox Text2
Height = 375
Index = 4
Left = 2400
TabIndex = 16
Text = "0"
Top = 3000
Width = 855
End
Begin VB.TextBox Text2
Height = 375
Index = 3
Left = 2400
TabIndex = 15
Text = "0"
Top = 2520
Width = 855
End
Begin VB.TextBox Text2
Height = 375
Index = 2
Left = 2400
TabIndex = 14
Text = "0"
Top = 2040
Width = 855
End
Begin VB.TextBox Text2
Height = 375
Index = 1
Left = 2400
TabIndex = 13
Text = "0"
Top = 1560
Width = 855
End
Begin VB.CommandButton Command2
Caption = "读取"
Height = 495
Left = 4320
TabIndex = 5
Top = 1080
Width = 855
End
Begin VB.TextBox Text2
Height = 375
Index = 0
Left = 2400
TabIndex = 3
Text = "0"
Top = 1080
Width = 855
End
Begin VB.TextBox Text1
Height = 375
Left = 2520
TabIndex = 1
Text = "192.168.0.253"
Top = 360
Width = 1455
End
Begin VB.CommandButton Command1
Caption = "连接"
Height = 495
Left = 4200
TabIndex = 0
Top = 360
Width = 1215
End
Begin MSWinsockLib.Winsock wsock
Left = 480
Top = 3960
_ExtentX = 741
_ExtentY = 741
_Version = 393216
End
Begin VB.Label Label1
Caption = "INPUT2"
Height = 255
Index = 7
Left = 960
TabIndex = 12
Top = 1560
Width = 1095
End
Begin VB.Label Label1
Caption = "INPUT3"
Height = 255
Index = 6
Left = 960
TabIndex = 11
Top = 2040
Width = 1095
End
Begin VB.Label Label1
Caption = "INPUT4"
Height = 255
Index = 5
Left = 960
TabIndex = 10
Top = 2520
Width = 1095
End
Begin VB.Label Label1
Caption = "INPUT5"
Height = 255
Index = 4
Left = 960
TabIndex = 9
Top = 3000
Width = 1095
End
Begin VB.Label Label1
Caption = "INPUT6"
Height = 255
Index = 3
Left = 960
TabIndex = 8
Top = 3480
Width = 1095
End
Begin VB.Label Label1
Caption = "INPUT7"
Height = 255
Index = 2
Left = 960
TabIndex = 7
Top = 3960
Width = 1095
End
Begin VB.Label Label1
Caption = "INPUT8"
Height = 255
Index = 1
Left = 960
TabIndex = 6
Top = 4440
Width = 1095
End
Begin VB.Label Label1
Caption = "INPUT1"
Height = 255
Index = 0
Left = 960
TabIndex = 4
Top = 1080
Width = 1095
End
Begin VB.Label Label22
Caption = "DNIO8IP地址:"
Height = 255
Left = 840
TabIndex = 2
Top = 480
Width = 1455
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim channel(7) As Byte '保存IO状态
Private Sub Command1_Click()
If Command1.Caption = "连接" Then
wsock.Close
wsock.Connect Text1, 20001
Do
DoEvents
Loop Until wsock.State = 7
Command1.Caption = "关闭连接"
Command2.Enabled = True
Exit Sub
End If
If Command1.Caption = "关闭连接" Then
Command2.Enabled = False
Command1.Caption = "连接"
End If
End Sub
Private Sub Command2_Click()
Dim i, j As Long
Dim sc(3) As Byte
sc(0) = 1
sc(1) = 1
sc(2) = 1
For i = 0 To 7
sc(3) = i
wsock.SendData sc
For j = 0 To 65535
DoEvents
Next
Next
End Sub
Private Sub Form_Load()
Command2.Enabled = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
wsock.Close
End Sub
Private Sub wsock_DataArrival(ByVal bytesTotal As Long)
Dim strdata() As Byte
Dim i, j As Integer
i = wsock.BytesReceived
ReDim strdata(i)
wsock.GetData strdata, vbByte, i
If strdata(1) = 1 Then
If strdata(4) = 0 Then
Text2(strdata(3)) = "输入"
Else
Text2(strdata(3)) = "输出"
End If
Text3(strdata(3)) = strdata(5)
channel(strdata(3)) = strdata(5)
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -