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

📄 form1.vb

📁 为日本瑞萨苏州分公司做的一个温控系统
💻 VB
📖 第 1 页 / 共 3 页
字号:
        '
        'Button4
        '
        Me.Button4.ForeColor = System.Drawing.Color.FromArgb(CType(0, Byte), CType(192, Byte), CType(192, Byte))
        Me.Button4.Location = New System.Drawing.Point(816, 224)
        Me.Button4.Name = "Button4"
        Me.Button4.Size = New System.Drawing.Size(104, 40)
        Me.Button4.TabIndex = 26
        Me.Button4.Text = "不显示4#"
        '
        'Button3
        '
        Me.Button3.ForeColor = System.Drawing.Color.FromArgb(CType(0, Byte), CType(192, Byte), CType(192, Byte))
        Me.Button3.Location = New System.Drawing.Point(336, 224)
        Me.Button3.Name = "Button3"
        Me.Button3.Size = New System.Drawing.Size(104, 40)
        Me.Button3.TabIndex = 25
        Me.Button3.Text = "不显示3#"
        '
        'Button2
        '
        Me.Button2.ForeColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(192, Byte), CType(0, Byte))
        Me.Button2.Location = New System.Drawing.Point(600, 224)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(104, 40)
        Me.Button2.TabIndex = 24
        Me.Button2.Text = "不显示2#"
        '
        'Button1
        '
        Me.Button1.ForeColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(192, Byte), CType(0, Byte))
        Me.Button1.Location = New System.Drawing.Point(120, 224)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(104, 40)
        Me.Button1.TabIndex = 23
        Me.Button1.Text = "不显示1#"
        '
        'TabPage2
        '
        Me.TabPage2.Controls.Add(Me.Label23)
        Me.TabPage2.Controls.Add(Me.ComboBox1)
        Me.TabPage2.Controls.Add(Me.Label19)
        Me.TabPage2.Controls.Add(Me.AdjTxt)
        Me.TabPage2.Controls.Add(Me.Label18)
        Me.TabPage2.Location = New System.Drawing.Point(4, 28)
        Me.TabPage2.Name = "TabPage2"
        Me.TabPage2.Size = New System.Drawing.Size(968, 488)
        Me.TabPage2.TabIndex = 1
        Me.TabPage2.Text = "校准"
        '
        'ComboBox1
        '
        Me.ComboBox1.Items.AddRange(New Object() {"1#", "2#", "3#", "4#"})
        Me.ComboBox1.Location = New System.Drawing.Point(288, 128)
        Me.ComboBox1.Name = "ComboBox1"
        Me.ComboBox1.Size = New System.Drawing.Size(136, 27)
        Me.ComboBox1.TabIndex = 3
        Me.ComboBox1.Text = "ComboBox1"
        '
        'Label19
        '
        Me.Label19.ForeColor = System.Drawing.Color.Green
        Me.Label19.Location = New System.Drawing.Point(144, 128)
        Me.Label19.Name = "Label19"
        Me.Label19.Size = New System.Drawing.Size(144, 24)
        Me.Label19.TabIndex = 2
        Me.Label19.Text = "请选择校准号:"
        '
        'AdjTxt
        '
        Me.AdjTxt.Location = New System.Drawing.Point(288, 224)
        Me.AdjTxt.Name = "AdjTxt"
        Me.AdjTxt.Size = New System.Drawing.Size(144, 29)
        Me.AdjTxt.TabIndex = 1
        Me.AdjTxt.Text = "AdjTxt"
        '
        'Label18
        '
        Me.Label18.Font = New System.Drawing.Font("楷体_GB2312", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.Label18.ForeColor = System.Drawing.Color.Green
        Me.Label18.Location = New System.Drawing.Point(128, 232)
        Me.Label18.Name = "Label18"
        Me.Label18.Size = New System.Drawing.Size(168, 24)
        Me.Label18.TabIndex = 0
        Me.Label18.Text = "请输入校准温度:"
        '
        'TabPage3
        '
        Me.TabPage3.Controls.Add(Me.ComboBox3)
        Me.TabPage3.Controls.Add(Me.Label21)
        Me.TabPage3.Controls.Add(Me.ComboBox2)
        Me.TabPage3.Controls.Add(Me.Label20)
        Me.TabPage3.Location = New System.Drawing.Point(4, 28)
        Me.TabPage3.Name = "TabPage3"
        Me.TabPage3.Size = New System.Drawing.Size(968, 488)
        Me.TabPage3.TabIndex = 2
        Me.TabPage3.Text = "修改"
        '
        'ComboBox3
        '
        Me.ComboBox3.Items.AddRange(New Object() {"1#", "2#", "3#", "4#"})
        Me.ComboBox3.Location = New System.Drawing.Point(280, 208)
        Me.ComboBox3.Name = "ComboBox3"
        Me.ComboBox3.Size = New System.Drawing.Size(168, 27)
        Me.ComboBox3.TabIndex = 3
        Me.ComboBox3.Text = "ComboBox3"
        '
        'Label21
        '
        Me.Label21.ForeColor = System.Drawing.Color.Green
        Me.Label21.Location = New System.Drawing.Point(112, 216)
        Me.Label21.Name = "Label21"
        Me.Label21.Size = New System.Drawing.Size(176, 24)
        Me.Label21.TabIndex = 2
        Me.Label21.Text = "请选择修改MCU号:"
        '
        'ComboBox2
        '
        Me.ComboBox2.Items.AddRange(New Object() {"1#", "2#", "3#", "4#"})
        Me.ComboBox2.Location = New System.Drawing.Point(280, 112)
        Me.ComboBox2.Name = "ComboBox2"
        Me.ComboBox2.Size = New System.Drawing.Size(168, 27)
        Me.ComboBox2.TabIndex = 1
        Me.ComboBox2.Text = "ComboBox2"
        '
        'Label20
        '
        Me.Label20.ForeColor = System.Drawing.Color.Green
        Me.Label20.Location = New System.Drawing.Point(120, 112)
        Me.Label20.Name = "Label20"
        Me.Label20.Size = New System.Drawing.Size(160, 24)
        Me.Label20.TabIndex = 0
        Me.Label20.Text = "请选择原MCU号:"
        '
        'Label22
        '
        Me.Label22.ForeColor = System.Drawing.Color.Red
        Me.Label22.Location = New System.Drawing.Point(752, 24)
        Me.Label22.Name = "Label22"
        Me.Label22.Size = New System.Drawing.Size(192, 40)
        Me.Label22.TabIndex = 24
        Me.Label22.Text = "请先去掉不需显示的Bake号,然后按开始"
        '
        'Label23
        '
        Me.Label23.ForeColor = System.Drawing.Color.Maroon
        Me.Label23.Location = New System.Drawing.Point(496, 216)
        Me.Label23.Name = "Label23"
        Me.Label23.Size = New System.Drawing.Size(112, 40)
        Me.Label23.TabIndex = 4
        Me.Label23.Text = "按回车键确定此次输入"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(10, 22)
        Me.ClientSize = New System.Drawing.Size(1008, 678)
        Me.Controls.Add(Me.Label22)
        Me.Controls.Add(Me.TabControl1)
        Me.Controls.Add(Me.Label9)
        Me.Controls.Add(Me.StartBut)
        Me.Controls.Add(Me.MSComm1)
        Me.Controls.Add(Me.ExitBut)
        Me.Font = New System.Drawing.Font("宋体", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.ForeColor = System.Drawing.Color.Blue
        Me.MaximizeBox = False
        Me.Name = "Form1"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "电机测试平台基本输入输出测试例程"
        CType(Me.MSComm1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox2.ResumeLayout(False)
        Me.GroupBox3.ResumeLayout(False)
        Me.GroupBox4.ResumeLayout(False)
        Me.TabControl1.ResumeLayout(False)
        Me.TabPage1.ResumeLayout(False)
        Me.TabPage2.ResumeLayout(False)
        Me.TabPage3.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region
    REM  全局变量声明
    Dim SendData() As Byte  '发送数组
    Dim RecvData() As Byte  '接收数组
    Dim Flag As Boolean     '避免发送事件中断接收事件
    Dim ShowFlag1, ShowFlag2, ShowFlag3, ShowFlag4 As Boolean
    Public Shared frmMain As Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Form1.frmMain = Me
        REM 串行口初始化
        SCIinit(MSComm1, 1, "9600,N,8,1")

        REM 清空有关文本框 
        Txt11.Text = "" : Txt12.Text = "" : Txt13.Text = "" : Txt14.Text = ""
        Txt21.Text = "" : Txt22.Text = "" : Txt23.Text = "" : Txt24.Text = ""
        Txt31.Text = "" : Txt32.Text = "" : Txt33.Text = "" : Txt34.Text = ""
        Txt41.Text = "" : Txt42.Text = "" : Txt43.Text = "" : Txt44.Text = ""

        REM 标志初始化
        ShowFlag1 = True : ShowFlag2 = True : ShowFlag3 = True : ShowFlag4 = True

        REM 定时器每隔10秒中断一次
        Timer1.Interval = 1000 '''''''''''''''''''''''''0

    End Sub
    REM 单击"退出"按钮
    Private Sub ExitBut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitBut.Click

        REM 关闭串口
        If MSComm1.PortOpen = True Then MSComm1.PortOpen = False

        REM 卸载本窗体
        End '??????????????Application.Exit()

    End Sub
    REM 定时器1定时中断事件
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        ReDim SendData(4)
        Dim DelayTime As Integer
        Dim start As Long

        REM 每10秒发送接收所有数据的请求
        If ShowFlag1 = True Then SendRecv(1) '接收1#的数据
        If ShowFlag2 = True Then SendRecv(2) '接收2#的数据
        If ShowFlag3 = True Then SendRecv(3) '接收3#的数据
        If ShowFlag4 = True Then SendRecv(4) '接收4#的数据

    End Sub
    REM 单击"开始"按钮
    Private Sub StartBut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartBut.Click

        REM 允许定时器开始计时
        Timer1.Enabled = True
        Label22.Visible = False

    End Sub
    REM 选项卡切换
    Private Sub TabControl1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl1.Click

        Select Case TabControl1.SelectedIndex
            Case 0
                Timer1.Enabled = True
            Case 1
                ComboBox1.Text = "1#"
                AdjTxt.Text = ""
                Timer1.Enabled = False
            Case 2
                ComboBox2.Text = "1#"
                ComboBox3.Text = ""
                Timer1.Enabled = False
        End Select
    End Sub
    REM 校准当前温度
    Private Sub AdjTxt_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles AdjTxt.KeyPress
        If Asc(e.KeyChar) = 13 Then
            SendAdjust(Val(Microsoft.VisualBasic.Left(ComboBox1.Text, 1)), CByte(Asc("W")), Val(AdjTxt.Text))
        End If
    End Sub
    REM 修改MCU号
    Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox3.SelectedIndexChanged

        Dim no1, no2 As Byte
        no1 = Val(Microsoft.VisualBasic.Left(ComboBox2.Text, 1))
        no2 = Val(ComboBox3.Text)
        SendMCUno(no1, no2)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Button1.Text = "不显示1#" Then
            ShowFlag1 = False
            Button1.Text = "显示1#"
        Else
            ShowFlag1 = True
            Button1.Text = "不显示1#"
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If Button2.Text = "不显示2#" Then
            ShowFlag2 = False
            Button2.Text = "显示2#"
        Else
            ShowFlag2 = True
            Button2.Text = "不显示2#"
        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If Button3.Text = "不显示3#" Then
            ShowFlag3 = False
            Button3.Text = "显示3#"
        Else
            ShowFlag3 = True
            Button3.Text = "不显示3#"
        End If
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        If Button4.Text = "不显示4#" Then
            ShowFlag4 = False
            Button4.Text = "显示4#"
        Else
            ShowFlag4 = True
            Button4.Text = "不显示4#"
        End If
    End Sub
End Class

⌨️ 快捷键说明

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