📄 form1.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "mscomm32.ocx"
Begin VB.Form main
Caption = "SCADA Main Window"
ClientHeight = 2085
ClientLeft = 60
ClientTop = 3555
ClientWidth = 5790
LinkTopic = "Form1"
MDIChild = -1 'True
ScaleHeight = 2085
ScaleWidth = 5790
Begin VB.TextBox Text4
Height = 285
Left = 3360
TabIndex = 9
Text = "0"
Top = 1680
Width = 495
End
Begin VB.Timer Timer1
Interval = 1000
Left = 5160
Top = 480
End
Begin VB.TextBox Text3
Height = 285
Left = 3360
TabIndex = 6
Text = "0"
Top = 1320
Width = 495
End
Begin VB.TextBox Text2
Height = 285
Left = 3360
TabIndex = 5
Text = "0"
Top = 1020
Width = 495
End
Begin VB.CommandButton Command1
Caption = "Open"
Height = 285
Left = 4200
TabIndex = 4
Top = 600
Width = 855
End
Begin VB.TextBox Text1
Height = 285
Left = 3360
TabIndex = 2
Top = 600
Width = 495
End
Begin MSCommLib.MSComm MSComm1
Left = 1080
Top = 480
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
RThreshold = 1
RTSEnable = -1 'True
End
Begin VB.Label Label4
Caption = "Volts"
Height = 255
Left = 3960
TabIndex = 12
Top = 1320
Width = 615
End
Begin VB.Label Label1
Alignment = 2 'Center
AutoSize = -1 'True
Caption = "Power"
Height = 255
Index = 3
Left = 3960
TabIndex = 11
Top = 1560
Width = 465
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "Power"
Height = 255
Index = 2
Left = 1920
TabIndex = 10
Top = 1680
Width = 1095
End
Begin VB.Label Label5
Caption = " SCADA BASED LOAD SHEDDING MANAGEMENT"
BeginProperty Font
Name = "Arial Black"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H8000000D&
Height = 435
Left = 120
TabIndex = 8
Top = 0
Width = 6585
End
Begin VB.Label Label3
Caption = "Amps"
Height = 255
Left = 3960
TabIndex = 7
Top = 1080
Width = 735
End
Begin VB.Label Label2
Caption = "Port Number"
Height = 285
Left = 1920
TabIndex = 3
Top = 600
Width = 975
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "Voltage"
Height = 255
Index = 1
Left = 1920
TabIndex = 1
Top = 1350
Width = 1095
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "Current"
Height = 255
Index = 0
Left = 1920
TabIndex = 0
Top = 1050
Width = 1095
End
End
Attribute VB_Name = "main"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i, j, fno As Integer
Private Sub Command1_Click()
On Error GoTo portopenerroragain
MSComm1.CommPort = Int(Text1.Text)
MSComm1.PortOpen = True
i = 1
j = 1
Label2.Visible = False
Text1.Visible = False
Command1.Visible = False
Exit Sub
portopenerroragain:
MsgBox Error, vbCritical
End Sub
Private Sub Command2_Click()
Form1.Show
End Sub
Private Sub Command3_Click()
Form2.Show
End Sub
Private Sub Command4_Click()
Form3.Show
End Sub
Private Sub Form_Load()
On Error GoTo portopenerror
Label2.Visible = False
Text1.Visible = False
Command1.Visible = False
MSComm1.CommPort = 1
MSComm1.PortOpen = True
'Form2.Show
'Form3.Show
'Form1.Show
i = 1
j = 1
fno = FreeFile
Open "c:\log.dat" For Output As fno
Strr = " Data Type " & " " & "Value" & " " & "Date" & " " & "Time" & vbNewLine
Print #fno, Strr
Exit Sub
portopenerror:
MsgBox Error, vbCritical
Label2.Visible = True
Text1.Visible = True
Command1.Visible = True
Exit Sub
End Sub
Private Sub MSComm1_OnComm()
Str1 = MSComm1.Input
If Str1 <> "" Then
Str2 = Mid(Str1, 1, 1)
If Str2 = "C" Then
Text2.Text = Asc(Mid(Str1, 2, 1))
Text2.Text = Int(Text2.Text) / 360
Strr = "Current Value " & " " & Text2.Text & " " & Date & " " & Time
Print #fno, Strr
End If
If Str2 = "V" Then
Text3.Text = Asc(Mid(Str1, 2, 1))
Text3.Text = Int(Text3.Text) * 3.633
Strr = "Voltage Value " & " " & Text3.Text & " " & Date & " " & Time
Print #fno, Strr
End If
Text4.Text = Int(Text2.Text) * Int(Text3.Text)
End If
End Sub
Private Sub Timer1_Timer()
Form2.MSChart1.Column = 1
Form2.MSChart1.Data = Int(Text2.Text)
i = i + 1
Form3.MSChart1.Column = 1
Form3.MSChart1.Data = Int(Text3.Text)
j = j + 1
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -