📄 frmmain.frm
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "mswinsck.ocx"
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "comctl32.ocx"
Begin VB.Form frmMain
BackColor = &H8000000B&
BorderStyle = 1 'Fixed Single
Caption = "转换卡测试"
ClientHeight = 5385
ClientLeft = 45
ClientTop = 330
ClientWidth = 7725
BeginProperty Font
Name = "宋体"
Size = 9.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Icon = "frmMain.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
ScaleHeight = 5385
ScaleWidth = 7725
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command2
Caption = "自动发送"
Height = 355
Left = 950
TabIndex = 25
Top = 4560
Width = 1335
End
Begin VB.Timer Timer2
Enabled = 0 'False
Left = 240
Top = 4560
End
Begin ComctlLib.StatusBar Status1
Align = 2 'Align Bottom
Height = 375
Left = 0
TabIndex = 24
Top = 5010
Width = 7725
_ExtentX = 13626
_ExtentY = 661
Style = 1
SimpleText = ""
_Version = 327682
BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7}
NumPanels = 1
BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Object.Tag = ""
EndProperty
EndProperty
End
Begin VB.TextBox Text4
BackColor = &H00FFFFFF&
ForeColor = &H00FF0000&
Height = 285
Left = 120
Locked = -1 'True
MultiLine = -1 'True
TabIndex = 23
Top = 3360
Width = 5295
End
Begin VB.CommandButton Command1
Caption = "退 出"
Height = 355
Index = 1
Left = 3840
TabIndex = 20
Top = 4560
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "发 送"
Height = 355
Index = 0
Left = 2400
TabIndex = 19
Top = 4560
Width = 1335
End
Begin VB.Frame Frame2
Caption = "远程PLC设置"
Height = 2175
Left = 120
TabIndex = 8
Top = 1080
Width = 5295
Begin VB.OptionButton Option1
Caption = "写入数据"
Height = 255
Index = 1
Left = 3840
TabIndex = 17
Top = 480
Width = 1215
End
Begin VB.TextBox txtTCPSend
Height = 285
Left = 2520
TabIndex = 16
Top = 960
Width = 2415
End
Begin VB.OptionButton Option1
Caption = "读取数据"
Height = 255
Index = 0
Left = 2520
TabIndex = 15
Top = 480
Value = -1 'True
Width = 1215
End
Begin VB.TextBox Text3
Height = 300
Left = 1220
TabIndex = 14
Text = "5"
Top = 960
Width = 975
End
Begin VB.TextBox Text2
Height = 300
Left = 1220
TabIndex = 12
Text = "1536"
Top = 1480
Width = 975
End
Begin VB.TextBox Text1
Height = 300
Left = 1220
TabIndex = 10
Text = "11"
Top = 440
Width = 975
End
Begin VB.Label Label8
Caption = "如:100\200\300"
ForeColor = &H000000FF&
Height = 255
Left = 2520
TabIndex = 22
Top = 1680
Width = 2415
End
Begin VB.Label Label7
Caption = "注:数与数间用""\""分开"
ForeColor = &H000000FF&
Height = 255
Left = 2520
TabIndex = 21
Top = 1440
Width = 2415
End
Begin VB.Label Label5
Caption = "长 度"
Height = 255
Left = 240
TabIndex = 13
Top = 1040
Width = 735
End
Begin VB.Label Label3
Caption = "开始地址"
Height = 255
Left = 240
TabIndex = 11
Top = 1560
Width = 855
End
Begin VB.Label Label2
Caption = "从站号"
Height = 255
Left = 240
TabIndex = 9
Top = 480
Width = 735
End
End
Begin VB.Timer Timer1
Interval = 30
Left = 4320
Top = 6120
End
Begin VB.TextBox txtTCPRecv
BackColor = &H00FFFFFF&
ForeColor = &H00FF0000&
Height = 285
Left = 120
Locked = -1 'True
MultiLine = -1 'True
TabIndex = 3
Top = 4080
Width = 5295
End
Begin VB.Frame Frame1
Caption = "Winsock参数设置"
Height = 975
Left = 120
TabIndex = 0
Top = 0
Width = 5295
Begin MSWinsockLib.Winsock Winsock1
Left = 4800
Top = 480
_ExtentX = 741
_ExtentY = 741
_Version = 393216
End
Begin VB.CommandButton btnConnect
Caption = "连 接"
Height = 355
Left = 2880
TabIndex = 6
Top = 240
Width = 1935
End
Begin VB.TextBox txtRemoteIP
Height = 285
Left = 1200
TabIndex = 5
Text = "192.168.0.100"
Top = 600
Width = 1575
End
Begin VB.TextBox txtRemotePort
Height = 285
Left = 1200
TabIndex = 2
Text = "4660"
Top = 240
Width = 1575
End
Begin VB.Label lblState
AutoSize = -1 'True
Caption = "连接状态:关闭"
ForeColor = &H000000FF&
Height = 195
Left = 2880
TabIndex = 7
Top = 720
Width = 1365
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "远程主机IP"
Height = 195
Left = 120
TabIndex = 4
Top = 600
Width = 990
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "远程端口"
Height = 195
Left = 120
TabIndex = 1
Top = 240
Width = 780
End
End
Begin VB.Label Label6
Caption = "返回数据:"
Height = 255
Left = 120
TabIndex = 18
Top = 3720
Width = 975
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private bConnectedOK As Boolean
Dim blRead As Boolean
Dim bySend() As Byte
Dim strChar As String
Dim intsErr As Boolean
Dim intRxCount As Integer
Dim intTxCount As Integer
Private Sub btnConnect_Click()
On Error Resume Next
If Winsock1.state <> sckConnected Then
Winsock1.Connect Winsock1.RemoteHost, Winsock1.RemotePort
Else
MsgBox "连接已经建立!", vbExclamation, "警告"
End If
Exit Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -