📄 frmsetan.frm
字号:
VERSION 5.00
Begin VB.Form frmSetAN
Caption = "Form1"
ClientHeight = 8355
ClientLeft = 60
ClientTop = 345
ClientWidth = 10995
LinkTopic = "Form1"
ScaleHeight = 8355
ScaleWidth = 10995
StartUpPosition = 3 'Windows Default
Begin VB.TextBox textBeforeConverted
Height = 615
Left = 6480
TabIndex = 13
Top = 4200
Width = 1575
End
Begin VB.TextBox textAfterConverted
Height = 615
Left = 6480
TabIndex = 12
Top = 5160
Width = 1575
End
Begin VB.CommandButton butConvert10to16
Caption = "10->16"
Height = 615
Left = 6600
TabIndex = 11
Top = 6240
Width = 1215
End
Begin VB.CommandButton butConvert16to10
Caption = "16->10"
Height = 615
Left = 8640
TabIndex = 10
Top = 6240
Width = 1215
End
Begin VB.TextBox textA
Height = 495
Left = 1080
TabIndex = 5
Top = 1080
Width = 1695
End
Begin VB.TextBox textN
Height = 495
Left = 1080
TabIndex = 4
Top = 1680
Width = 1695
End
Begin VB.CommandButton butCancel
Caption = "退出"
Height = 495
Left = 3720
TabIndex = 3
Top = 1680
Width = 1215
End
Begin VB.CommandButton butSetAN
Caption = "设置"
Height = 495
Left = 3720
TabIndex = 2
Top = 1080
Width = 1215
End
Begin VB.TextBox textNodeAddress
Height = 495
Left = 1080
TabIndex = 1
Top = 480
Width = 1695
End
Begin VB.Timer Timer1
Left = 5880
Top = 1680
End
Begin VB.CommandButton butQueryAN
Caption = "查询"
Height = 495
Left = 3720
TabIndex = 0
Top = 480
Width = 1215
End
Begin VB.Label Label11
Caption = "A值转换"
BeginProperty Font
Name = "MS Sans Serif"
Size = 13.5
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 495
Left = 5760
TabIndex = 17
Top = 3480
Width = 1935
End
Begin VB.Label Label6
Caption = "10进制,精确到0.5"
Height = 375
Left = 8400
TabIndex = 16
Top = 4560
Width = 1575
End
Begin VB.Label Label7
Caption = "16进制"
Height = 375
Left = 8280
TabIndex = 15
Top = 5280
Width = 1695
End
Begin VB.Label Label9
Caption = "0X"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 5880
TabIndex = 14
Top = 5280
Width = 375
End
Begin VB.Image Image1
Height = 5580
Left = 0
Picture = "frmSetAN.frx":0000
Top = 2640
Width = 5625
End
Begin VB.Line Line1
X1 = 0
X2 = 9000
Y1 = 2640
Y2 = 2640
End
Begin VB.Label Label1
Caption = "请输入AN值(16进制,不包括0x)"
ForeColor = &H000000FF&
Height = 375
Left = 0
TabIndex = 9
Top = 120
Width = 3375
End
Begin VB.Label Label2
Caption = "A"
Height = 375
Left = 600
TabIndex = 8
Top = 1200
Width = 375
End
Begin VB.Label Label3
Caption = "N"
Height = 375
Left = 600
TabIndex = 7
Top = 1800
Width = 375
End
Begin VB.Label Label10
Caption = "节点地址"
Height = 375
Left = 120
TabIndex = 6
Top = 600
Width = 855
End
End
Attribute VB_Name = "frmSetAN"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim timeout As Boolean
Private Sub butCancel_Click()
If (MsgBox("确定退出吗?", vbOKCancel, "Confirm") = vbOK) Then
Unload Me
MainForm.Show
End If
End Sub
Private Sub butConvert10to16_Click()
Dim doubleBeforeConverted As Double
Dim dotpos As Integer
Dim afterdot As Integer ' 0 1 0.5 1
Dim beforedot As Integer
If Trim(textBeforeConverted.Text) = "" Then
MsgBox "请输入要转换的A", vbOKOnly, "error"
Exit Sub
End If
dotpos = InStr(textBeforeConverted.Text, ".")
If dotpos = 0 Then
'没有小数点
afterdot = 0
beforedot = CInt(textBeforeConverted.Text)
Else
'如果有小数点
beforedot = CInt(Left(Trim(textBeforeConverted.Text), dotpos - 1))
If (Len(Trim(textBeforeConverted.Text))) - dotpos = 1 Then
'1位小数
Select Case Right(Trim(textBeforeConverted.Text), 1)
Case "5"
afterdot = 1
Case "0"
afterdot = 0
Case Else
MsgBox "1位小数只能为0.0,0.5", vbOKOnly, "error"
Exit Sub
End Select
Else
MsgBox "小数点后最多为1位", vbOKOnly, "error"
Exit Sub
End If
End If
textAfterConverted.Text = Hex(beforedot * 2 + afterdot)
End Sub
Private Sub butConvert16to10_Click()
If Trim(textAfterConverted.Text) = "" Then
MsgBox "要转换的16进制A不能为空", , "Error"
Exit Sub
End If
textBeforeConverted.Text = CStr(Val("&H" & textAfterConverted.Text) / 2)
End Sub
Private Sub butQueryAN_Click()
Dim strNodeAddress As String
Dim i As Integer
strNodeAddress = Trim(textNodeAddress)
If (strNodeAddress = "") Then
MsgBox "请输入节点地址", vbOKOnly, "Error"
Exit Sub
End If
If (Len(strNodeAddress) > 2) Then
MsgBox "请输入正确的节点地址信息(长度小于2)", vbOKOnly, "Error"
Exit Sub
End If
If Not isHex(Left(strNodeAddress, 1)) Then
MsgBox "请输入正确的节点地址", vbOKOnly, "Error"
Exit Sub
End If
If Not isHex(Right(strNodeAddress, 1)) Then
MsgBox "请输入正确的节点地址", vbOKOnly, "Error"
Exit Sub
End If
'通过串口查询AN
If (isCommOpen = False) Then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -