Attribute VB_Name = "Module1"
Rem 串行口初始化
Public Sub SCIinit(Msc1 As MSComm, ByVal COMx As Byte, ByVal SCIFormat As String)
   If Msc1.PortOpen = True Then
      Ms1.PortOpen = False
   End If
   Msc1.CommPort = COMx                   '串行口号
   Msc1.Settings = SCIFormat              '定义传输格式
   Msc1.InputMode = comInputModeBinary    '二进制数据格式
   Msc1.RThreshold = 0                    '关闭串行中断
   Msc1.InputLen = 2                      '一次读取缓冲区全部数据
   Msc1.PortOpen = True                   '打开串行口
   Msc1.InBufferCount = 0
End Sub


Public Function Gettmp(ADvalue As Integer) As Single
  Dim i As Integer
  Dim A_value
  Dim T_value
  A_value = Array(16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192)
  T_value = Array(79, 56, 43, 34, 27, 21, 15, 10, 5, -1, -6, -11)
  If ADvalue < A_value(0) Then
     Gettmp = T_value
  End If
  If ADvalue >= A_value(10) Then
     Gettmp = T_value
  End If
  For i = 1 To 9
      If ADvalue >= A_value(i) And ADvalue < A_value(i + 1) Then
         Gettmp = T_value(i) + ((T_value(i + 1) - T_value(i)) / (A_value(i + 1) - A_value(i))) * (ADvalue - A_value(i))
      End If
  Next i
End Function
