📄 form1.frm
字号:
Top = 2400
Width = 2415
End
Begin VB.TextBox Text8
Height = 270
Left = 3360
TabIndex = 16
Top = 360
Width = 495
End
Begin VB.TextBox Text7
Height = 270
Left = 2640
TabIndex = 15
Top = 360
Width = 495
End
End
Begin VB.Frame Frame2
Caption = "设置区"
Height = 3255
Left = 2760
TabIndex = 2
Top = 0
Width = 4935
Begin VB.Frame Frame10
Caption = "输入地址"
Height = 615
Left = 120
TabIndex = 57
Top = 240
Width = 4695
Begin VB.CommandButton Command11
Caption = "确定"
Height = 255
Left = 3960
TabIndex = 60
Top = 240
Width = 615
End
Begin VB.ComboBox setadr
Height = 300
Left = 3000
TabIndex = 58
Top = 240
Width = 855
End
Begin VB.Label Label29
Caption = "输入需要设置的下位机地址号"
Height = 255
Left = 120
TabIndex = 59
Top = 240
Width = 2895
End
End
Begin VB.Frame Frame8
Caption = "设定新参数"
Height = 615
Left = 120
TabIndex = 47
Top = 960
Width = 4695
Begin VB.ComboBox newbaud
Height = 300
Left = 720
TabIndex = 51
Top = 240
Width = 855
End
Begin VB.ComboBox newadr
Height = 300
Left = 3000
TabIndex = 50
Top = 240
Width = 855
End
Begin VB.CommandButton Command7
Caption = "确定"
Height = 255
Left = 1680
TabIndex = 49
Top = 240
Width = 615
End
Begin VB.CommandButton Command8
Caption = "确定"
Height = 255
Left = 3960
TabIndex = 48
Top = 240
Width = 615
End
Begin VB.Label Label27
Caption = "波特率"
Height = 255
Left = 120
TabIndex = 53
Top = 240
Width = 615
End
Begin VB.Label Label28
Caption = "地址号"
Height = 255
Left = 2400
TabIndex = 52
Top = 240
Width = 615
End
End
Begin VB.Frame Frame6
Caption = "设定上下限"
Height = 1455
Left = 120
TabIndex = 25
Top = 1680
Width = 4695
Begin VB.CommandButton Command5
Caption = "设置"
Height = 255
Left = 3960
TabIndex = 41
Top = 960
Width = 615
End
Begin VB.CommandButton Command2
Caption = "设置"
Height = 255
Left = 3960
TabIndex = 40
Top = 600
Width = 615
End
Begin VB.CommandButton Command1
Caption = "设置"
Height = 255
Left = 3960
TabIndex = 39
Top = 240
Width = 615
End
Begin VB.ComboBox aouttop
Height = 300
Left = 1680
TabIndex = 30
Top = 240
Width = 735
End
Begin VB.ComboBox acinputb
Height = 300
Left = 1680
TabIndex = 29
Top = 600
Width = 735
End
Begin VB.ComboBox acinputtop
Height = 300
Left = 2880
TabIndex = 28
Top = 600
Width = 735
End
Begin VB.ComboBox dcoutb
Height = 300
Left = 1680
TabIndex = 27
Top = 960
Width = 735
End
Begin VB.ComboBox dcouttop
Height = 300
Left = 2880
TabIndex = 26
Top = 960
Width = 735
End
Begin VB.Label Label20
Caption = "上限"
Height = 255
Left = 2520
TabIndex = 38
Top = 960
Width = 375
End
Begin VB.Label Label19
Caption = "下限"
Height = 255
Left = 1320
TabIndex = 37
Top = 960
Width = 375
End
Begin VB.Label Label6
Caption = "上限"
Height = 255
Left = 2520
TabIndex = 36
Top = 600
Width = 495
End
Begin VB.Label Label5
Caption = "下限"
Height = 255
Left = 1320
TabIndex = 35
Top = 600
Width = 375
End
Begin VB.Label Label1
Caption = "上限"
Height = 255
Left = 1320
TabIndex = 34
Top = 240
Width = 375
End
Begin VB.Label Label18
Caption = "交流电压V(AC)"
Height = 255
Left = 120
TabIndex = 33
Top = 600
Width = 1215
End
Begin VB.Label Label17
Caption = "直流电压V(DC)"
Height = 255
Left = 120
TabIndex = 32
Top = 960
Width = 1215
End
Begin VB.Label Label15
Caption = "直流电流A(DC) "
Height = 255
Left = 120
TabIndex = 31
Top = 240
Width = 1335
End
End
Begin VB.TextBox Text12
Height = 270
Left = 3960
TabIndex = 22
Top = 1920
Width = 495
End
Begin VB.TextBox Text13
Height = 270
Left = 3960
TabIndex = 21
Top = 2280
Width = 495
End
End
Begin VB.Timer Timer2
Enabled = 0 'False
Interval = 400
Left = 6120
Top = 6240
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 400
Left = 5640
Top = 6240
End
Begin MSCommLib.MSComm MSComm1
Left = 4920
Top = 6120
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public select1 As Byte
Public adropen As Boolean
'--------------------------------------------------------------------
'设置输出电流的上限按钮
'--------------------------------------------------------------------
Private Sub Command1_Click()
Dim First_chr(0 To 11) As Byte
Dim vsend As Variant
Dim i As Integer
Dim j As String
Dim top As String
Dim top1 As String
Dim k As Integer
Dim n As Integer
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
If st.Enabled = True Then
MsgBox "串口没打开", vbOKOnly & vbInformation, "提示打开串口"
Exit Sub
End If
If adropen = False Then
MsgBox "你没有选择要设置的从机地址,请选择要设置的从机地址", vbOKOnly & vbInformation, "提示"
Exit Sub
End If
If aouttop.Text = "" Then
MsgBox "你没有输入选择电流的上限", vbOKOnly & vbInformation, "提示"
Exit Sub
End If
top = "0" & Mid$(aouttop.Text, 1, 1)
top1 = Replace(Right$(aouttop.Text, 3), ".", "")
MSComm1.InputMode = comInputModeBinary
First_chr(0) = &H5E
First_chr(1) = &H10
First_chr(2) = Val(Trim("&H" & setadr.Text))
First_chr(3) = &HB2
First_chr(4) = &HD0
First_chr(5) = &H3
First_chr(6) = &H90
First_chr(7) = Val(Trim("&H" & top))
First_chr(8) = Val(Trim("&H" & top1))
For n = 1 To 8
k = k + First_chr(n)
If k > 255 Then
k = k - 256
End If
Next n
First_chr(9) = Val("&H" & Hex$(k))
k = Not First_chr(9)
k = k + 1
First_chr(10) = Val("&H" & Hex$(k))
First_chr(11) = &HD
send.Text = ""
For i = 0 To 11
j = Hex$(First_chr(i))
If Len(j) = 1 Then
j = "0" & j
End If
send.Text = send.Text & j
Next i
vsend = First_chr()
Call SendData(First_chr)
End Sub
Private Sub Command11_Click()
'--------------------------------------------------------------------
'输入要设置的从机地址号的按钮
'--------------------------------------------------------------------
If st.Enabled = True Then
MsgBox "串口没打开", vbOKOnly & vbInformation, "提示打开串口"
Exit Sub
End If
If setadr.Text = "" Then
MsgBox "选择地址号不能为空", vbOKOnly & vbInformation, "提示"
Exit Sub
End If
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
setadr.Text = Trim$(setadr.Text)
adropen = True
MsgBox "现在可以对该地址号的从机进行设置了", vbOKOnly & vbInformation, "提示"
End Sub
'--------------------------------------------------------------------
'设置交流输入电压的按钮
'--------------------------------------------------------------------
Private Sub Command2_Click()
Dim First_chr(0 To 13) As Byte
Dim vsend As Variant
Dim i As Integer
Dim j As String
Dim top As String
Dim bellow As String
Dim top1 As String
Dim bellow1 As String
Dim k As Integer
Dim n As Integer
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
If st.Enabled = True Then
MsgBox "串口没打开", vbOKOnly & vbInformation, "提示打开串口"
Exit Sub
End If
If adropen = False Then
MsgBox "你没有选择要设置的从机地址,请选择要设置的从机地址", vbOKOnly & vbInformation, "提示"
Exit Sub
End If
If acinputb.Text = "" Then
MsgBox "你没有选择交流电压的下限", vbOKOnly & vbInformation, "提示"
Exit Sub
End If
If acinputtop.Text = "" Then
MsgBox "你没有选择交流电压的上限", vbOKOnly & vbInformation, "提示"
Exit Sub
End If
top = "0" & Left$(acinputtop.Text, 1)
top1 = Right$(acinputtop.Text, 2)
bellow = "0" & Left$(acinputb.Text, 1)
bellow1 = Right$(acinputb.Text, 2)
MSComm1.InputMode = comInputModeBinary
First_chr(0) = &H5E
First_chr(1) = &H10
First_chr(2) = Val(Trim("&H" & setadr.Text))
First_chr(3) = &HB2
First_chr(4) = &HB0
First_chr(5) = &H5
First_chr(6) = &H8C
First_chr(7) = Val(Trim("&H" & top))
First_chr(8) = Val(Trim("&H" & top1))
First_chr(9) = Val(Trim("&H" & bellow))
First_chr(10) = Val(Trim("&H" & bellow1))
For n = 1 To 10
k = k + First_chr(n)
If k > 255 Then
k = k - 256
End If
Next n
First_chr(11) = Val("&H" & Hex$(k))
k = Not First_chr(11)
k = k + 1
First_chr(12) = Val("&H" & Hex$(k))
First_chr(13) = &HD
send.Text = ""
For i = 0 To 13
j = Hex$(First_chr(i))
If Len(j) = 1 Then
j = "0" & j
End If
send.Text = send.Text & j
Next i
vsend = First_chr()
Call SendData(First_chr)
End Sub
Private Sub Command3_Click()
Dim string1 As String
Dim x As Byte
Dim y As Byte
Dim First_chr(0 To 11) As Byte
Dim vsend As Variant
Dim i As Integer
Dim j As String
Dim k As Integer
Dim n As Integer
If st.Enabled = True Then
MsgBox "串口没打开", vbOKOnly & vbInformation, "提示打开串口"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -