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

📄 temperature.frm

📁 keilc程序+proteus+vb+串口调试
💻 FRM
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   5475
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   6600
   LinkTopic       =   "Form1"
   ScaleHeight     =   5475
   ScaleWidth      =   6600
   StartUpPosition =   3  '窗口缺省
   Begin VB.PictureBox Picture1 
      AutoRedraw      =   -1  'True
      BackColor       =   &H00404040&
      Height          =   2475
      Left            =   480
      ScaleHeight     =   2415
      ScaleWidth      =   3735
      TabIndex        =   5
      Top             =   2640
      Width           =   3795
   End
   Begin VB.PictureBox Picture2 
      AutoRedraw      =   -1  'True
      Height          =   5355
      Left            =   4980
      Picture         =   "temperature.frx":0000
      ScaleHeight     =   12.59
      ScaleMode       =   0  'User
      ScaleWidth      =   2.71
      TabIndex        =   4
      Top             =   60
      Width           =   1155
   End
   Begin VB.TextBox Text1 
      Height          =   555
      Left            =   1980
      TabIndex        =   3
      Top             =   1020
      Width           =   1395
   End
   Begin VB.CommandButton Command1 
      Caption         =   "发送"
      Height          =   435
      Left            =   780
      TabIndex        =   2
      Top             =   1080
      Width           =   915
   End
   Begin VB.TextBox Text3 
      Height          =   495
      Left            =   1980
      TabIndex        =   1
      Top             =   300
      Width           =   1395
   End
   Begin VB.CommandButton Command2 
      Caption         =   "退出"
      Height          =   435
      Left            =   720
      TabIndex        =   0
      Top             =   1920
      Width           =   1035
   End
   Begin MSCommLib.MSComm MSComm1 
      Left            =   60
      Top             =   0
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      DTREnable       =   -1  'True
   End
   Begin VB.Label Label1 
      Caption         =   "温度:"
      Height          =   255
      Left            =   2220
      TabIndex        =   9
      Top             =   2040
      Width           =   555
   End
   Begin VB.Label Label2 
      Caption         =   "25"
      Height          =   195
      Left            =   2940
      TabIndex        =   8
      Top             =   2040
      Width           =   195
   End
   Begin VB.Label Label3 
      Caption         =   "。"
      Height          =   195
      Left            =   3180
      TabIndex        =   7
      Top             =   1920
      Width           =   75
   End
   Begin VB.Label Label4 
      Caption         =   "C"
      Height          =   255
      Left            =   3300
      TabIndex        =   6
      Top             =   2040
      Width           =   195
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim temper As Integer
Dim line_a As Integer
Dim line_b As Integer
Dim time_s As Integer
Dim bt As Integer

Private Sub Command1_Click() '写#1
'Dim num As Integer
'Dim outaddr(0) As Byte
'Dim outcode(0) As Byte
Dim outdata(0) As Byte

Data = Val(Text1.Text)
'outaddr(0) = CByte(0) '地址
'outcode(0) = CByte(1) '命令字
outdata(0) = CByte(Data) '数据

'MSComm1.OutBufferCount = 0
'MSComm1.Output = outaddr() '动态数组
'MSComm1.OutBufferCount = 0
'MSComm1.Output = outcode() '动态数组
MSComm1.OutBufferCount = 0
MSComm1.Output = outdata() '动态数组





End Sub

Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
MSComm1.CommPort = 4
MSComm1.Settings = "9600,n,8,1"
MSComm1.PortOpen = True
MSComm1.InputMode = comInputModeBinary
MSComm1.RThreshold = 1
bt = 0
Call line_init
End Sub

Private Sub MSComm1_OnComm()
Dim indata As Variant
Dim bte(0) As Byte '定义接受数组(2个)
Dim rec_0 As String
'Dim rec_1 As String
Select Case MSComm1.CommEvent
Case comEvReceive
indata = MSComm1.Input
'bte(0) = indata(0)
'bte(1) = indata(1)
'If bte(0) = 0 Then
'Text2.Text = Val("&H" & Hex(bte(1)))
'End If
'If bte(0) = 1 Then
'Text3.Text = Val("&H" & Hex(bte(1)))
'End If
'If bte(0) = 2 Then
'Text6.Text = Val("&H" & Hex(bte(1)))
'End If

'bte(0) = AscB(indata)
bte(0) = indata(0)
'bte(1) = indata(1)
'Text3.Text = Val("&H" & Hex(bte(0)))

rec_0 = bte(0)
'rec_1 = bte(1)
If bt = 0 Then
Text3.Text = Chr(rec_0) '+ Chr(rec_1)
bt = bt + 1
ElseIf bt = 1 Then
Text3.Text = Text3.Text + Chr(rec_0)
bt = 0
temper = Val(Text3.Text)
Call line_draw


End If



'Text3.Text = "vv"
MSComm1.InBufferCount = 0
End Select
End Sub
Sub line_init()

Show
Picture1.Scale (0, 100)-(100, 0)
time_s = 0
Picture2.DrawWidth = 3
line_b = 25
Picture2.Line (1.3, 11.8)-(1.3, 7.5), vbRed
End Sub
Sub line_draw()

Label2.Caption = temper
line_a = line_b
line_b = temper
Picture1.Line (time_s, line_a)-(time_s + 1, line_b), vbGreen
Picture2.Cls
Picture2.Line (1.3, 11)-(1.3, 7.5 - temper * 0.11), vbRed
time_s = time_s + 1

If time_s = 100 Then
time_s = 0
Picture1.Cls
End If
End Sub

⌨️ 快捷键说明

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