大家好,最近在搞一個設計,是單片機通過上位機在VB上面顯示溫度曲線,但是我程式程式不是很會寫,各位大神能幫幫嗎
uj5u.com熱心網友回復:
google vb mschartuj5u.com熱心網友回復:
什么意思啊??uj5u.com熱心網友回復:
google我說的關鍵字,自己就能找到答案。uj5u.com熱心網友回復:
親,可以幫我寫一個嗎,應該很快吧,幫幫我好,我有大部分代碼的,但是我不會畫界面而已,你幫我畫畫,補充補充好嗎?uj5u.com熱心網友回復:
Dim x As VariantDim s As Variant
Private Sub Command1_Click()
Timer1.Enabled = True
MSComm1.RThreshold = 1
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
MSComm1.RThreshold = 0
End Sub
Private Sub Command3_Click()
Dim b(1) As Byte
b(0) = &H2
MSComm1.Output = b
End Sub
Private Sub Command4_Click()
Dim b(1) As Byte
b(0) = &H0
MSComm1.Output = b
End Sub
Private Sub Command5_Click()
End
End Sub
Private Sub 全開_Click()
Dim b(1) As Byte
b(0) = &H3
MSComm1.Output = b
End Sub
Private Sub Command7_Click()
Dim b(1) As Byte
b(0) = &H1
MSComm1.Output = b
End Sub
Private Sub Command8_Click()
Picture1.Cls
End Sub
Private Sub Form_Load()
With MSComm1
.CommPort = 1 '使用COM1
.Settings = "9600,N,8,1" '設定通信口引數
.InBufferSize = 1 '設定接識訓沖區為1位元組
.OutBufferSize = 1 '設定發送緩沖區為1位元組
.InputMode = comInputModeBinary '設定接收資料模式為二進制形式
.InputLen = 1 '設定Input 一次從接識訓沖讀取位元組數為1
.SThreshold = 1 '設定Output 一次從發送緩沖讀取位元組數為1
.RThreshold = 1 '設定接收一個位元組產生OnComm事件
.InBufferCount = 0 '清除接識訓沖區
.OutBufferCount = 0 '清除發送緩沖區
.PortOpen = True '打開通信口
End With
End Sub
Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent '判斷MSComm控制元件的當前狀態
Dim temp As Variant, buffer() As Byte
Case comEventOverrun
Text2.Text = ""
Text2.SetFocus
Exit Sub
Case comEventRxOver
Text2.Text = ""
Text2.SetFocus3
Exit Sub
Case comEventTxFull
Text2.Text = ""
Text2.SetFocus
Exit Sub
Case comEvReceive '收到Rthreshold個位元組產生的接收事件
'temp = MSComm1.Input
'buffer = temp
'For i = 0 To UBound(buffer)
's = s & (buffer(i))
'Next i
s = AscB(MSComm1.Input)
Text1.Text = s
MSComm1.InBufferCount = 0
RThreshold = 0 '關閉OnComm事件接收
End Select
End Sub
Private Sub Picture1_Click()
Picture1.Scale (0, 50)-(50, 0)
Picture1.Line (5, 5)-(5, 50)
Picture1.Line (5, 5)-(50, 5)
Picture1.CurrentX = 3:
Picture1.CurrentY = 50:
Picture1.Print "Y (。C)"
Picture1.CurrentX = 43:
Picture1.CurrentY = 4:
Picture1.Print "X(ms)"
End Sub
Private Sub Timer1_Timer()
x = x + 0.1
Picture1.PSet (x, s), RGB(24, 32, 5)
Picture1.Line (x - 0.5, s)-(x, s)
If x = 20 Then x = 0
End Sub
Private Sub Timer2_Timer()
T.Text = Format(Now, "yyyy年mm月dd日 ") & WeekdayName(Weekday(Now)) & Format(Now, " hh:mm:ss")
End Sub
uj5u.com熱心網友回復:
媽呀!筆記本散熱還要搞個控制程式轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/121756.html
標籤:控件
下一篇:跪求大神幫我修改一下程式啊~拜謝
