⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 is also very important for life
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      TabIndex        =   11
      Text            =   "Text4"
      Top             =   840
      Width           =   1335
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H00C0E0FF&
      Caption         =   "Head Movement"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   20.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   1695
      Left            =   9240
      TabIndex        =   14
      Top             =   4320
      Width           =   3975
      Begin VB.Line Line7 
         BorderWidth     =   6
         X1              =   3960
         X2              =   3960
         Y1              =   0
         Y2              =   1680
      End
      Begin VB.Line Line6 
         BorderWidth     =   6
         X1              =   0
         X2              =   3960
         Y1              =   1680
         Y2              =   1680
      End
      Begin VB.Line Line5 
         BorderWidth     =   6
         X1              =   0
         X2              =   0
         Y1              =   0
         Y2              =   1680
      End
      Begin VB.Line Line4 
         BorderWidth     =   6
         X1              =   0
         X2              =   3960
         Y1              =   0
         Y2              =   0
      End
      Begin VB.Line Line3 
         BorderColor     =   &H0000FF00&
         BorderWidth     =   15
         X1              =   2640
         X2              =   3240
         Y1              =   1320
         Y2              =   960
      End
      Begin VB.Line Line2 
         BorderColor     =   &H0000FF00&
         BorderWidth     =   15
         X1              =   2640
         X2              =   3240
         Y1              =   600
         Y2              =   960
      End
      Begin VB.Line Line1 
         BorderColor     =   &H0000FF00&
         BorderWidth     =   15
         X1              =   480
         X2              =   2880
         Y1              =   960
         Y2              =   960
      End
   End
   Begin VB.CommandButton Command5 
      BackColor       =   &H000000FF&
      Caption         =   "STOP"
      BeginProperty Font 
         Name            =   "Arial Black"
         Size            =   20.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   480
      Left            =   6720
      Style           =   1  'Graphical
      TabIndex        =   19
      Top             =   4920
      Width           =   1335
   End
   Begin VB.Timer Timer5 
      Interval        =   10
      Left            =   120
      Top             =   600
   End
   Begin VB.Label Label1 
      Height          =   615
      Left            =   840
      TabIndex        =   4
      Top             =   720
      Width           =   1095
   End
   Begin VB.Shape Shape2 
      FillColor       =   &H000000FF&
      FillStyle       =   0  'Solid
      Height          =   1695
      Left            =   5640
      Shape           =   3  'Circle
      Top             =   4320
      Width           =   3615
   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 Relays, IpSwitch, OFC  As Integer
Dim Sw1, Sw2, Sw3, Sw4 As Boolean
Dim relay As String
Dim Buf As String
Dim e As Integer
Private Sub Command3_Click()
Form2.Data1.Recordset.AddNew
    Form2.Data1.Recordset.Fields(0) = Format(Date, "dd/mm/yy")
    Form2.Data1.Recordset.Fields(1) = Format(Time, "hh:mm")
    Form2.Data1.Recordset.Fields(2) = Frame3.Caption
    Form2.Data1.UpdateRecord
        Timer3.Enabled = True
        Timer5.Enabled = False
        Timer1.Enabled = False
        Timer2.Enabled = False
        Timer4.Enabled = False
        
End Sub

Private Sub Command4_Click()
Form2.Data1.Recordset.AddNew
    Form2.Data1.Recordset.Fields(0) = Format(Date, "dd/mm/yy")
    Form2.Data1.Recordset.Fields(1) = Format(Time, "hh:mm")
    Form2.Data1.Recordset.Fields(2) = Frame4.Caption
    Form2.Data1.UpdateRecord
        Timer4.Enabled = True
        Timer5.Enabled = False
        Timer1.Enabled = False
        Timer3.Enabled = False
        Timer2.Enabled = False

End Sub

Private Sub Command5_Click()
Form2.Data1.Recordset.AddNew
    Form2.Data1.Recordset.Fields(0) = Format(Date, "dd/mm/yy")
    Form2.Data1.Recordset.Fields(1) = Format(Time, "hh:mm")
    Form2.Data1.Recordset.Fields(2) = "OFF"
    Form2.Data1.UpdateRecord

        MSComm1.Output = "{5B00}"
        Frame4.Visible = False
        Frame1.Visible = False
        Frame2.Visible = False
        Frame3.Visible = False
        Timer4.Enabled = False
        Timer5.Enabled = False
        Timer1.Enabled = False
        Timer3.Enabled = False
        Timer2.Enabled = False


End Sub

Private Sub Command6_Click()
Form2.Visible = True
End Sub

Private Sub Command7_Click()
Form5.Visible = True

End Sub

Private Sub Command8_Click()
    Form2.Data1.Recordset.AddNew
    Form2.Data1.Recordset.Fields(0) = Format(Date, "dd/mm/yy")
    Form2.Data1.Recordset.Fields(1) = Format(Time, "hh:mm")
    Form2.Data1.Recordset.Fields(2) = "OFF"
    Form2.Data1.UpdateRecord

        MSComm1.Output = "{5B00}"
        Frame4.Visible = False
        Frame1.Visible = False
        Frame2.Visible = False
        Frame3.Visible = False
        Timer4.Enabled = False
        Timer5.Enabled = False
        Timer1.Enabled = False
        Timer3.Enabled = False
        Timer2.Enabled = False
End Sub

Private Sub Form_Load()
e = 1
        MSComm1.PortOpen = True
      FindComPort
        MSComm1.Output = "{1B00}"
        Sleep (100)
        MSComm1.Output = "{5B00}"
        Sleep (100)
        MSComm1.Output = "{1D00}"
        Sleep (100)
        Frame1.Visible = False
        Frame2.Visible = False
        Frame3.Visible = False
        Frame4.Visible = False
        Timer1.Enabled = False
        Timer2.Enabled = False
        Timer3.Enabled = False
        Timer4.Enabled = False
        Timer5.Enabled = False
        
        MSComm1.Output = "{27}"
        Sleep (100)
End Sub
Public Sub FindComPort()

        On Error GoTo Port2

        If (MSComm1.PortOpen = True) Then MSComm1.PortOpen = False
        MSComm1.CommPort = 1
        MSComm1.PortOpen = True
        MSComm1.Output = "{3D}"
        Sleep (100)
        Buf = MSComm1.Input
        If (Len(Buf) > 2) Then Exit Sub

Port2:

        On Error GoTo Port3

        If (MSComm1.PortOpen = True) Then MSComm1.PortOpen = False
        MSComm1.CommPort = 2
        MSComm1.PortOpen = True
        MSComm1.Output = "{3D}"
        Sleep (100)
        Buf = MSComm1.Input
        If (Len(Buf) > 2) Then Exit Sub

Port3:


        On Error GoTo port4

        If (MSComm1.PortOpen = True) Then MSComm1.PortOpen = False
        MSComm1.CommPort = 3
        MSComm1.PortOpen = True
        MSComm1.Output = "{3D}"
        Sleep (100)
        Buf = MSComm1.Input
        If (Len(Buf) > 2) Then Exit Sub

port4:

    MsgBox "Couldn't find in Com1 - Com4", vbCritical, "Communication Error."


End Sub
Private Sub Command1_Click()

'        MSComm1.Output = "{5B01}"
        Frame1.Visible = True
        Frame2.Visible = False
        Frame3.Visible = False
        Frame4.Visible = False
Form2.Data1.Recordset.AddNew
    Form2.Data1.Recordset.Fields(0) = Format(Date, "dd/mm/yy")
    Form2.Data1.Recordset.Fields(1) = Format(Time, "hh:mm")
    Form2.Data1.Recordset.Fields(2) = Frame1.Caption
    Form2.Data1.UpdateRecord
        Timer1.Enabled = True
        
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False

Timer5.Enabled = False
End Sub

Private Sub Command2_Click()
Form2.Data1.Recordset.AddNew
    Form2.Data1.Recordset.Fields(0) = Format(Date, "dd/mm/yy")
    Form2.Data1.Recordset.Fields(1) = Format(Time, "hh:mm")
    Form2.Data1.Recordset.Fields(2) = Frame2.Caption
    Form2.Data1.UpdateRecord
        Timer2.Enabled = True
        Timer5.Enabled = False
        Timer1.Enabled = False
        Timer3.Enabled = False
        Timer4.Enabled = False


End Sub

Private Sub Form_Unload(Cancel As Integer)

        MSComm1.Output = "{5B00}"

End Sub
Private Sub Timer1_Timer()
        
        Text1.Text = Rnd * 20
        If (Text1.Text > 10) Then
        Frame1.ForeColor = &HFF8080
        Frame1.BackColor = &HFFC0FF
        Else
        Frame1.BackColor = &HFF8080
        Frame1.ForeColor = &HFFC0FF
        End If
        
        MSComm1.Output = "{5B01}"
        Frame1.Visible = True
        Frame2.Visible = False
        Frame3.Visible = False
        Frame4.Visible = False
        Timer1.Enabled = True
        Timer5.Enabled = False
      
End Sub

Private Sub Timer2_Timer()

        Text2.Text = Rnd * 20
        If (Text2.Text > 10) Then
        Frame2.ForeColor = &HFF8080
        Frame2.BackColor = &HFFC0FF
        Else
        Frame2.BackColor = &HFF8080
        Frame2.ForeColor = &HFFC0FF
        End If
        MSComm1.Output = "{5B02}"
        Frame2.Visible = True
        Frame1.Visible = False
        Frame3.Visible = False
        Frame4.Visible = False
        Timer2.Enabled = True
        Timer5.Enabled = False
        
End Sub

Private Sub Timer3_Timer()

        Text3.Text = Rnd * 20
        If (Text3.Text > 10) Then
        Frame3.ForeColor = &HFF8080
        Frame3.BackColor = &HFFC0FF
        Else
        Frame3.BackColor = &HFF8080
        Frame3.ForeColor = &HFFC0FF
        End If
        MSComm1.Output = "{5B04}"
        Frame3.Visible = True
        Frame1.Visible = False
        Frame2.Visible = False
        Frame4.Visible = False
        Timer3.Enabled = True
        Timer5.Enabled = False
End Sub

Private Sub Timer4_Timer()

        Text4.Text = Rnd * 20
        If (Text4.Text > 10) Then
        Frame4.ForeColor = &HFF8080
        Frame4.BackColor = &HFFC0FF
        Else
        Frame4.BackColor = &HFF8080
        Frame4.ForeColor = &HFFC0FF
        End If
        
        MSComm1.Output = "{5B08}"
        Frame4.Visible = True
        Frame1.Visible = False
        Frame2.Visible = False
        Frame3.Visible = False
        Timer4.Enabled = True
        Timer5.Enabled = False
End Sub
''Private Sub Timer5_Timer()
''
''Timer4.Enabled = False
''Timer1.Enabled = False
''Timer3.Enabled = False
''Timer2.Enabled = False
''
''
''
''            MSComm1.Output = "{3D}"
''            Sleep (100)
''            Buf = MSComm1.Input
''            If Buf <> "" Then
''            OFC = Asc(Mid$(Buf, 2, 1))
''            End If
''           OFC = &H4
''           OFC = &H1
''            If (OFC And &H1) = &H1 And (OFC And &H2) = &H2 Then
''
''                            MSComm1.Output = "{5B00}"
''
''            End If
''
''            If (OFC And &H2) = &H2 And (OFC And &H4) = &H4 Then
''
''                            MSComm1.Output = "{5B00}"
''            End If
''
''            If (OFC And &H4) = &H4 And (OFC And &H8) = &H8 Then
''
''                            MSComm1.Output = "{5B00}"
''            End If
''
''            If (OFC And &H8) = &H8 And (OFC And &H1) = &H1 Then
''
''                            MSComm1.Output = "{5B00}"
''            End If
''
''
''            If (OFC And &H1) = &H1 Then
''                MSComm1.Output = "{5B01}"
''                Frame1.Visible = True
''                Frame2.Visible = False
''                Frame3.Visible = False
''                Frame4.Visible = False
''                Timer1.Enabled = True
''            End If
''
''            If (OFC And &H2) = &H2 Then
''                MSComm1.Output = "{5B02}"
''                Frame2.Visible = True
''                Frame1.Visible = False
''                Frame3.Visible = False
''                Frame4.Visible = False
''                Timer2.Enabled = True
''            End If
'''OFC = &H4
''            If (OFC And &H4) = &H4 Then
''                MSComm1.Output = "{5B04}"
''                Frame3.Visible = True
''                Frame1.Visible = False
''                Frame2.Visible = False
''                Frame4.Visible = False
''                Timer3.Enabled = True
''            End If
'''OFC = &H8
''            If (OFC And &H8) = &H8 Then
''                MSComm1.Output = "{5B08}"
''                Frame4.Visible = True
''                Frame1.Visible = False
''                Frame2.Visible = False
''                Frame3.Visible = False
''                Timer4.Enabled = True
''            End If
''
''
''End Sub

Private Sub Timer6_Timer()
'Text5.Text = e
'e = e + 3
'If e > 60 Then e = 1
MSComm1.Output = "{40}"
Sleep (100)
relay = MSComm1.Input
load1 = ChrToVal(relay)
Text5.Text = Format(load1, "####.00")
If (Text5.Text) > 70 Then
'MSComm1.Output = "{5B00}"
    Timer1.Enabled = True
    Timer2.Enabled = False
    Timer3.Enabled = False
    Timer4.Enabled = False
    Timer5.Enabled = False
 Else
  Timer2.Enabled = False
  Timer1.Enabled = False
 MSComm1.Output = "{5B00}"
 End If
End Sub


Public Function ChrToVal(Str)
    If Str <> "" Then
    ChrToVal = CInt(Mid$(Str, 2, 4))
    End If
End Function

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -