📄 ch365frm.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 4290
ClientLeft = 60
ClientTop = 345
ClientWidth = 3015
LinkTopic = "Form1"
ScaleHeight = 4290
ScaleWidth = 3015
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox txtByte
Height = 375
Left = 1560
MaxLength = 4
TabIndex = 4
Text = "Text3"
Top = 2760
Width = 975
End
Begin VB.TextBox txtAddr
Height = 375
Left = 1560
MaxLength = 4
TabIndex = 3
Text = "Text2"
Top = 2280
Width = 975
End
Begin VB.CommandButton CommandRead
Caption = "读数据"
Height = 495
Left = 600
TabIndex = 2
Top = 960
Width = 1815
End
Begin VB.CommandButton CommandWrite
Caption = "写数据"
Height = 495
Left = 600
TabIndex = 1
Top = 1560
Width = 1815
End
Begin VB.CommandButton btnOpen
Caption = "打开设备"
Height = 495
Left = 600
TabIndex = 0
Top = 360
Width = 1815
End
Begin VB.Label Label4
Caption = "地址为直接地址"
Height = 255
Left = 600
TabIndex = 8
Top = 3720
Width = 1455
End
Begin VB.Label Label3
Caption = "(以上为十六进制)"
Height = 255
Left = 600
TabIndex = 7
Top = 3360
Width = 1695
End
Begin VB.Label Label1
Caption = "地址(0-ff)"
Height = 255
Left = 360
TabIndex = 6
Top = 2280
Width = 975
End
Begin VB.Label Label2
Caption = "字节(BYTE)"
Height = 255
Left = 240
TabIndex = 5
Top = 2880
Width = 1095
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim mOpen As Long
Dim mPCH365_IO_REG As mCH365_IO_REG
Private Sub btnOpen_Click()
If LoadLibrary("CH365DLL.DLL") = Null Then ' 加载DLL失败,可能未安装到系统中
MsgBox "无法加载CH365的DLL"
End If
mOpen = CH365mOpenDevice(0, True, True)
If mOpen = -1 Then ' 使用之前必须打开设备
MsgBox "无法打开CH365设备"
End If
End Sub
Private Sub CommandRead_Click()
Dim iAddr As Long
Dim ChByte As Byte
iAddr = hextobcd(txtAddr.Text)
If (mOpen <> -1) Then
If (CH365ReadIoByte(iAddr, ChByte)) Then
txtByte.Text = Hex(ChByte)
MsgBox "Read success!"
Else
MsgBox "Read failed!"
End If
End If
End Sub
Private Sub CommandWrite_Click()
Dim mAddr As Long
Dim mVal As Byte
mAddr = CLng(hextobcd(txtAddr.Text))
mVal = hextobcd(txtByte.Text)
If (mOpen <> -1) Then
If CH365WriteIoByte(mAddr, mVal) Then
MsgBox "Write success!"
Else
MsgBox "Write failed!"
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -