📄 frmrepair.frm
字号:
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 6
Left = 4395
TabIndex = 16
Text = "0.0"
Top = 600
Width = 615
End
Begin VB.TextBox txtDT
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 7
Left = 5055
TabIndex = 17
Text = "0.0"
Top = 600
Width = 615
End
Begin VB.TextBox txtDT
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 8
Left = 5700
TabIndex = 18
Text = "0.0"
Top = 600
Width = 615
End
Begin VB.TextBox txtDT
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 9
Left = 6360
TabIndex = 19
Text = "0.0"
Top = 600
Width = 615
End
Begin VB.Label Label1
Caption = "上:"
Height = 255
Index = 0
Left = 0
TabIndex = 26
Top = 240
Width = 735
End
Begin VB.Label Label1
Caption = "下:"
Height = 255
Index = 1
Left = 0
TabIndex = 25
Top = 600
Width = 735
End
End
Begin VB.PictureBox Picture1
Height = 375
Left = 0
ScaleHeight = 315
ScaleWidth = 7155
TabIndex = 22
Top = 0
Width = 7215
Begin VB.Label Label2
Caption = " 1区 2区 3区 4区 5区 6区 7区 8区 9区 10区"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 0
Left = 360
TabIndex = 23
Top = 120
Width = 6615
End
End
Begin VB.CommandButton CancelButton
Caption = "取消"
Height = 375
Left = 5640
TabIndex = 21
Top = 1920
Width = 1095
End
Begin VB.CommandButton OKButton
Caption = "确定"
Default = -1 'True
Height = 375
Left = 480
TabIndex = 20
Top = 1920
Width = 1095
End
End
Attribute VB_Name = "frmRepair"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim IsNotFirst As Boolean
Private Sub CancelButton_Click()
Me.Hide
frmMain.Enabled = True
End Sub
Private Sub Form_Activate()
Dim i As Long, j As Long
SetDlgBackColor Me
For i = 0 To txtUT.UBound
txtUT(i).Visible = frmMain.lbUT(i).Visible
txtDT(i).Visible = frmMain.lbDT(i).Visible
Next
j = (txtUT(1).Left - txtUT(0).Left) * (5 - iCurrentOption)
Label1(1).Visible = oOption(iCurrentOption).bOption(22)
Label2(0).Width = 6615 - j
Me.Width = 7425 - j
CancelButton.Left = 5520 - j
Picture1.Width = 7215 - j
Picture2.Width = 7215 - j
If Not oOption(iCurrentOption).bOption(22) Then
j = 600
Else
j = 0
End If
Picture2.Height = 1215 - j
OKButton.Top = 1920 - j
CancelButton.Top = 1920 - j
Me.Height = 2865 - j
End Sub
Private Sub Form_Load()
bTimeEnd = True
OKButton.Enabled = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call CancelButton_Click
Cancel = 1
End Sub
Private Sub Timer1_Timer()
Dim ss As String
Dim j As Long, i As Long
On Error Resume Next
If (Not Ack) Then
Exit Sub
End If
Timer1.Enabled = False
For i = 0 To 1
ss = frmMain.PLCCommand(1, 3, DeviceAbsAdd("D353"), iCurrentOption + 5, 0, "") '+ txtuT.Count
If ss <> "" Then
ss = Mid(ss, 8, (iCurrentOption + 5) * 4)
For j = 0 To iCurrentOption + 4
txtUT(j).Text = Format(AltNegative(Hex2Dec(Mid(ss, 4 * j + 1, 4))) / 10#, "0.0")
Next
Exit For
End If
TimeDelay 300
Next
For i = 0 To 1
ss = frmMain.PLCCommand(1, 3, DeviceAbsAdd("D363"), (iCurrentOption + 5), 0, "") '+ txtDT.Count
If ss <> "" Then
ss = Mid(ss, 8, (iCurrentOption + 5) * 4)
For j = 0 To (iCurrentOption + 4)
txtDT(j).Text = Format(AltNegative(Hex2Dec(Mid(ss, 4 * j + 1, 4))) / 10#, "0.0")
Next
Exit For
End If
TimeDelay 300
Next
bTimeEnd = False
OKButton.Enabled = True
IsNotFirst = True
Ack = False
End Sub
Private Sub Timer2_Timer()
Dim i As Long, j As Long
Dim ss As String
On Error GoTo Errhandle
If Not Ack Then
Exit Sub
End If
Timer2.Enabled = False
frmInfo.Show , Me
frmInfo.ProgressBar1.Value = 0
For j = 0 To txtUT.UBound
If txtUT(j).Tag = "1" Then
For i = 0 To 1
ss = frmMain.PLCCommand(1, 6, DeviceAbsAdd("D" & 353 + j), AltNegative(CLng(Val(txtUT(j).Text)) * 10), 0, "")
If ss = "" Then
TimeDelay 300
Else
txtUT(j).Tag = 0
WritePrivateProfileString "Repair", "UT" & CStr(j), txtUT(j).Text, iniFile
Exit For
End If
Next
If ss = "" Then
frmMain.sbStatusBar.Panels(1).Text = Time & " D" & 353 + j & "下载失败!"
Call frmMain.AddErrorLog(frmMain.sbStatusBar.Panels(1).Text)
End If
End If
frmInfo.ProgressBar1.Value = (j + 1) * 1000 / (txtUT.Count + txtDT.Count)
Next
For j = 0 To txtDT.UBound
If txtDT(j).Tag = "1" Then
For i = 0 To 1
ss = frmMain.PLCCommand(1, 6, DeviceAbsAdd("D" & 363 + j), AltNegative(CLng(Val(txtDT(j).Text) * 10)), 0, "")
If ss = "" Then
TimeDelay 300
Else
txtDT(j).Tag = 0
WritePrivateProfileString "Repair", "DT" & CStr(j), txtDT(j).Text, iniFile
Exit For
End If
Next
If ss = "" Then
frmMain.sbStatusBar.Panels(1).Text = Time & " D" & 363 + j & "下载失败!"
Call frmMain.AddErrorLog(frmMain.sbStatusBar.Panels(1).Text)
End If
End If
frmInfo.ProgressBar1.Value = (txtUT.Count + j + 1) * 1000 / (txtUT.Count + txtDT.Count)
Next
GoTo Out
Errhandle:
frmMain.sbStatusBar.Panels(1).Text = Time & "-温度补偿 错误:" & Err.description
Call frmMain.AddErrorLog(frmMain.sbStatusBar.Panels(1).Text)
Err.Clear
Out:
OKButton.Enabled = True
frmInfo.Hide
bTimeEnd = False
Ack = False
End Sub
Private Sub txtDT_Change(Index As Integer)
If IsNotFirst Then
txtDT(Index).Tag = "1"
End If
End Sub
Private Sub txtDT_LostFocus(Index As Integer)
If (Val(txtDT(Index).Text) < -50 Or Val(txtDT(Index).Text) > 50) Then
MsgBox "设置值超限!", vbCritical + vbOKOnly, "警告"
txtDT(Index).Text = 50
End If
End Sub
Private Sub txtUT_Change(Index As Integer)
If IsNotFirst Then
txtUT(Index).Tag = "1"
End If
End Sub
Private Function AltNegative(ByVal v As Long) As Long
If v < 0 Then
AltNegative = 65536 + v
ElseIf v < 32768 Then
AltNegative = v
Else
AltNegative = v - 65536
End If
End Function
Private Sub OKButton_Click()
If bTimeEnd Then
Exit Sub
End If
frmMain.sbStatusBar.Panels(1).Text = ""
bTimeEnd = True
OKButton.Enabled = False
Timer2.Enabled = True
End Sub
Private Sub txtUT_LostFocus(Index As Integer)
If (Val(txtUT(Index).Text) < -50 Or Val(txtUT(Index).Text) > 50) Then
MsgBox "设置值超限!", vbCritical + vbOKOnly, "警告"
txtUT(Index).Text = 50
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -