台灣最大程式設計社群網站
線上人數
1229
 
會員總數:246038
討論主題:189625
歡迎您免費加入會員
討論區列表 >> VB6 >> 可以幫忙看看是哪邊有問題嗎???
[]  
[我要回覆]
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
可以幫忙看看是哪邊有問題嗎???
價值 : 50 QP  點閱數:1502 回應數:0
樓主

CiReN
門外漢
0 3
40 7
發送站內信

捐贈 VP 給 CiReN

我這個程式處理出來之後所能感測的溫度繪圖每次都只能繪出插電後的第一次感測其他都不能....請問是我程式出錯還是怎樣呢?下面是我的VB程式碼希望有高手能幫忙一下謝謝








Dim Tempernow As Variant
Dim Temper(3600, 1)
Dim Temper1() As Byte
Private Sub Cmdexit_Click()
MSComm1.PortOpen = False
End
End Sub



Private Sub Form_Load()
MSComm1.CommPort = 1
MSComm1.Settings = "9600,n,8,1"
MSComm1.InputLen = 1
MSComm1.InputMode = comInputModeBinary
MSComm1.RThreshold = 1
MSComm1.PortOpen = True
For i = 0 To 3600
If i / 600 = i \ 600 Then
Temper(i, 0) = Str(i / 60) & "¤À"
End If
Next i
MSChart1.ChartData = Temper
Txtdisp.Text = ""
Timer1.Interval = 30
Timer2.Interval = 5000
Timer1.Enabled = True
Timer2.Enabled = True
End Sub

Private Sub MSChart1_PointSelected(Series As Integer, DataPoint As Integer, MouseFlags As Integer, Cancel As Integer)

Txtdisp.Text = Str(DataPoint \ 60) & "分" & Str(DataPoint Mod 60) & "秒" & "溫度為" & Str(Temper(DataPoint, 1))
End Sub

Private Sub MSComm1_OnComm()
If MSComm1.CommEvent = comEvReceive Then
Tempernow = MSComm1.Input
Temper1 = Tempernow
End If
End Sub

Private Sub Timer1_Timer()
ReDim Preserve Temper1(0)
nowtime = Val(Mid$(Time$, 4, 2)) * 60 + Val(Right$(Time$, 2))
Temper(nowtime, 1) = Temper1(0) * 20 / 200
If nowtime = 0 Then
For i = 1 To 3600
Temper(i, 1) = Empty
Next i
End If
End Sub

Private Sub Timer2_Timer()
MSChart1.ChartData = Temper
End Sub


搜尋相關Tags的文章: [ VB ] , [ 溫度 ] ,
本篇文章發表於2007-12-05 20:21
目前尚無任何回覆
   

回覆
如要回應,請先登入.