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

📄 main windows.frm

📁 上位机是VB设置成的界面;下位机是用C编释的51单片机的温度采集模块。
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         EndProperty
         Height          =   255
         Left            =   120
         TabIndex        =   7
         Top             =   960
         Width           =   855
      End
      Begin VB.Label Label2 
         Alignment       =   2  'Center
         Caption         =   "通信端口:"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   120
         TabIndex        =   6
         Top             =   480
         Width           =   855
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "系统状态"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   975
      Left            =   120
      TabIndex        =   0
      Top             =   5160
      Width           =   3255
      Begin VB.TextBox Text3 
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   15.75
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   615
         Left            =   120
         TabIndex        =   15
         Top             =   240
         Width           =   3015
      End
   End
   Begin VB.Label Label11 
      BackStyle       =   0  'Transparent
      Caption         =   "现在时刻"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   0
      TabIndex        =   19
      Top             =   360
      Width           =   1335
   End
   Begin VB.Label Label10 
      BackStyle       =   0  'Transparent
      Caption         =   "摄氏温度"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   0
      TabIndex        =   17
      Top             =   1800
      Width           =   1335
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "华氏温度"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   0
      TabIndex        =   16
      Top             =   1080
      Width           =   1335
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
Label6.Caption = 1
Label7.Caption = 9600
Label8.Caption = "100"
Label9.Caption = "-20"
End Sub
        
'*************************************************************
'开始接收
'*************************************************************
Private Sub cmdReceive_Click()
If binReceiveflag Then
frmMain.cmdReceive.Caption = "开始接收"
   Else
  If Not frmMain.ctrMSComm.PortOpen Then
    frmMain.ctrMSComm.PortOpen = True   '打开串行口
  End If
    frmMain.ctrMSComm.InputLen = 0
    frmMain.ctrMSComm.InputMode = 0
    frmMain.ctrMSComm.InBufferCount = 0
    frmMain.ctrMSComm.RThreshold = 1
    frmMain.cmdReceive.Caption = "停止接收"
    End If
    binReceiveflag = Not binReceiveflag
    
'*********************************************************************
'绘制坐标系
'*********************************************************************
Picture1.ScaleMode = 1 '以VB的基本单位作为建立坐标轴以及绘制图形的单位;
Picture1.Refresh
Picture1.CurrentX = Picture1.ScaleWidth - 100
Picture1.CurrentY = Picture1.ScaleHeight / 2 - 30
Picture1.Print "T"
Picture1.CurrentX = Picture1.ScaleLeft + 20
Picture1.CurrentY = Picture1.ScaleTop + 20
Picture1.Print "C"
'***************************************************************
'画纵坐标
'***************************************************************
For i = Picture1.ScaleLeft + 300 To Picture1.ScaleWidth - 300 Step (Picture1.ScaleWidth - Picture1.ScaleLeft - 600) / 6
Picture1.CurrentX = i
Picture1.Line (i, Picture1.ScaleTop)-(i, Picture1.ScaleHeight - 300)
Picture1.CurrentX = i - 100
CurrentY = Picture1.ScaleHeight - 300
Picture1.Print (i * 60) \ (Picture1.ScaleWidth - Picture1.ScaleLeft - 600) - 2
Next i
'***************************************************************
'画上半平面的横坐标
'***************************************************************
For j = Picture1.ScaleTop To Picture1.ScaleHeight / 2 Step ((Picture1.ScaleHeight / 2 - Picture1.ScaleTop) / 10)
Picture1.CurrentY = j
Picture1.Line (Picture1.ScaleLeft + 300, j)-(Picture1.ScaleWidth - 300, j)
Picture1.CurrentX = Picture1.ScaleLeft + 80
Picture1.CurrentY = j
Picture1.Print ((Picture1.ScaleHeight / 2 - j) * 200) \ (Picture1.ScaleHeight)
Next j
'****************************************************************
'画下半平面的横坐标
'****************************************************************
For k = Picture1.ScaleHeight / 2 To Picture1.ScaleHeight Step ((Picture1.ScaleHeight - Picture1.ScaleHeight / 2) / 10)
Picture1.CurrentY = k
Picture1.Line (Picture1.ScaleLeft + 300, k)-(Picture1.ScaleWidth - 300, k)
Picture1.CurrentX = Picture1.ScaleLeft + 80
Picture1.CurrentY = k
Picture1.Print -((k - Picture1.ScaleHeight / 2) * 200) \ (Picture1.ScaleHeight)
Next k
    
End Sub
'**************************************************************
'日志管理
'***************************************************************
Private Sub Cmdrecord_Click()
frmLog.Show
End Sub
   
Private Sub Timer1_Timer()
   Dim a As Integer
   Dim str1 As String
   Static x     As Long
   Static y     As Long
   Dim y1 As Integer
   Text1.Text = ""
   Text2.Text = ""
   a = 0
   Text4.Text = Time$()
   If ctrMSComm.InBufferCount > 0 Then  '程序检查输入缓冲区中是否有数据,若有数据
   a = ctrMSComm.Input
   End If
   If a > 155 Then
   b0 = a \ 100
   b1 = b0 \ 10
   a = b0 + b1 - 1
   Else
   a = a
   End If
   Text1.Text = str(a) + "°C"          '则将此数据读取后,指定给文本框的Text属性
   Text2.Text = str(a + 273.16) + "k"
   y1 = Picture1.ScaleHeight / 2 - (a * Picture1.ScaleHeight) / 200
   Picture1.Line (x, y)-(x + ((Picture1.ScaleWidth - 600 - Picture1.ScaleLeft)) / 60, y1)
   x = x + (Picture1.ScaleWidth - 600 - Picture1.ScaleLeft) / 60
   y = y1

   If x >= Picture1.ScaleWidth Then
     SavePicture Picture1.Image, "c:\temp.bmp" '保存图画,可以根据实际需要命名图片
     x = Picture1.ScaleLeft + 300
      Picture1.Cls '清屏重画
      '绘制坐标系
'*********************************************************************
Picture1.ScaleMode = 1 '以VB的基本单位作为建立坐标轴以及绘制图形的单位;
Picture1.Refresh
Picture1.CurrentX = Picture1.ScaleWidth - 100
Picture1.CurrentY = Picture1.ScaleHeight / 2 - 30
Picture1.Print "T"
Picture1.CurrentX = Picture1.ScaleLeft + 20
Picture1.CurrentY = Picture1.ScaleTop + 20
Picture1.Print "C"
'***************************************************************
'画纵坐标
'***************************************************************
For i = Picture1.ScaleLeft + 300 To Picture1.ScaleWidth - 300 Step (Picture1.ScaleWidth - Picture1.ScaleLeft - 600) / 6
Picture1.CurrentX = i
Picture1.Line (i, Picture1.ScaleTop)-(i, Picture1.ScaleHeight - 300)
Picture1.CurrentX = i - 100
CurrentY = Picture1.ScaleHeight - 300
Picture1.Print (i * 60) \ (Picture1.ScaleWidth - Picture1.ScaleLeft - 600) - 2
Next i
'***************************************************************
'画上半平面的横坐标
'***************************************************************
For j = Picture1.ScaleTop To Picture1.ScaleHeight / 2 Step ((Picture1.ScaleHeight / 2 - Picture1.ScaleTop) / 10)
Picture1.CurrentY = j
Picture1.Line (Picture1.ScaleLeft + 300, j)-(Picture1.ScaleWidth - 300, j)
Picture1.CurrentX = Picture1.ScaleLeft + 80
Picture1.CurrentY = j
Picture1.Print ((Picture1.ScaleHeight / 2 - j) * 200) \ (Picture1.ScaleHeight)
Next j
'****************************************************************
'画下半平面的横坐标
'****************************************************************
For k = Picture1.ScaleHeight / 2 To Picture1.ScaleHeight Step ((Picture1.ScaleHeight - Picture1.ScaleHeight / 2) / 10)
Picture1.CurrentY = k
Picture1.Line (Picture1.ScaleLeft + 300, k)-(Picture1.ScaleWidth - 300, k)
Picture1.CurrentX = Picture1.ScaleLeft + 80
Picture1.CurrentY = k
Picture1.Print -((k - Picture1.ScaleHeight / 2) * 200) \ (Picture1.ScaleHeight)
Next k
End If
'****************************************************************
'判断通信状况
'****************************************************************
   If y0 > 125 Or y0 < -55 Then
   Text3.Text = "串口通信异常"
   Else
   Text3.Text = "通信状况良好"
   End If
   
'********************************************************************
'数据的存储    //每采一次数据存储一次
'********************************************************************
    str1 = Text4.Text + Space(10) + Text1.Text
    Open "temp.txt" For Append As #1
    Print #1, str1
    Close #1

'*********************************************************************
'设置过温报警
'*********************************************************************
   If a < -20 Or a > 100 Then
   For j0 = 1 To 100
   Beep
   Next j0
   End If

End Sub



⌨️ 快捷键说明

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