?? led點陣式顯示屏上位機程序.txt
字號:
LED點陣式顯示屏上位機程序
Public Sub SendData()
Dim contton As String
Dim BUFFER As Variant '定義一個Variant 變量
Dim counter As Integer '進度條
Dim x As Long '保存字的位置.
Dim num, ch, sum As Integer '計算字的個數
Dim DATA As String * 4 '接收數據
Dim se(0) As Byte
Dim pp, cal As Integer
cal = 0
MainForm.Text2.Text = ""
contton = MainForm.Text1.Text
sum = Len(contton)
If contton = "" Then
MsgBox "顯示區沒有內容,請輸入!", vbOKOnly, "警告!"
Exit Sub
ElseIf sum > 20 Then
MsgBox "最多發送20個字符!", vbOKOnly, "警告!"
Else
If MainForm.MSComm1.PortOpen = True Then
MainForm.MSComm1.PortOpen = False
End If
MainForm.MSComm1.Settings = "9600,N,8,1" '通過SettingForm設置串口號,并打開串口。
MainForm.MSComm1.PortOpen = True
Yulanform.Show
Yulanform.Text1.Text = ""
se(0) = &HA
ch = se(0)
For i = 1 To 10 '發送起始符
Yulanform.Text1.Text = Yulanform.Text1.Text + Format$(Hex$(ch), "@@ ")
MainForm.MSComm1.Output = se
Next i '發送第11,12字節
Yulanform.Text1.Text = Yulanform.Text1.Text + " 十字節起始符0A" + vbCrLf
Yulanform.Text1.Text = Yulanform.Text1.Text + vbCrLf
se(0) = &H0
ch = se(0)
For i = 1 To 2 '發送兩個空字節,預留功能
Yulanform.Text1.Text = Yulanform.Text1.Text + Format$(Hex$(ch), "@@ ")
MainForm.MSComm1.Output = se
Next i '發送第11,12字節
Yulanform.Text1.Text = Yulanform.Text1.Text + " 兩個空字節,預留功能" + vbCrLf
Yulanform.Text1.Text = Yulanform.Text1.Text + vbCrLf
num = Len(contton) ' 計算長度,發送字符
For k = 1 To num '發送漢字,直到將所有漢字發送完畢
pp = Asc(Mid(contton, k, 1))
If pp < 0 Then
cal = cal + 1
End If
Next k
num = num + cal
counter = num * 16 '初始化進度條
MainForm.ProgressBar1.Min = 0
MainForm.ProgressBar1.Max = counter
MainForm.ProgressBar1.Value = 0
counter = 0
num = num - cal
For k = 1 To num '發送漢字,直到將所有漢字發送完畢
pp = Asc(Mid(contton, k, 1))
If pp < 0 Then
Call GetHZZM(Mid(contton, k, 1))
For i = 1 To 32 '將單個漢字一個字節一個字節的發送
If i Mod 2 = 1 Then
se(0) = ZMDZ(i)
ch = se(0)
Yulanform.Text1.Text = Yulanform.Text1.Text + Format$(Hex$(ch), "@@ ")
MainForm.MSComm1.Output = se
counter = counter + 1
MainForm.ProgressBar1.Value = counter '進度條指示進度
End If
Next i
For i = 1 To 32
If i Mod 2 = 0 Then
se(0) = ZMDZ(i)
ch = se(0)
Yulanform.Text1.Text = Yulanform.Text1.Text + Format$(Hex$(ch), "@@ ")
MainForm.MSComm1.Output = se
counter = counter + 1
MainForm.ProgressBar1.Value = counter '進度條指示進度
End If
Next i
Yulanform.Text1.Text = Yulanform.Text1.Text + " " + "“" + Mid(contton, k, 1) + "”" + vbCrLf
Yulanform.Text1.Text = Yulanform.Text1.Text + vbCrLf
Else
Call GetASCZM(Mid(contton, k, 1))
For i = 1 To 16 '將單個漢字一個字節一個字節的發送
se(0) = ZMDZ1(i)
ch = se(0)
Yulanform.Text1.Text = Yulanform.Text1.Text + Format$(Hex$(ch), "@@ ")
MainForm.MSComm1.Output = se
counter = counter + 1
MainForm.ProgressBar1.Value = counter '進度條指示進度
Next i
Yulanform.Text1.Text = Yulanform.Text1.Text + " " + "“" + Mid(contton, k, 1) + "”" + vbCrLf
Yulanform.Text1.Text = Yulanform.Text1.Text + vbCrLf
End If
MainForm.Text2.Text = MainForm.Text2.Text + Mid(contton, k, 1)
Next k
ch = Way(0) '發送花樣選擇
MainForm.MSComm1.Output = Way
Yulanform.Text1.Text = Yulanform.Text1.Text + Format$(Hex$(ch), "@@ ")
Yulanform.Text1.Text = Yulanform.Text1.Text + " 花樣選擇" + vbCrLf
Yulanform.Text1.Text = Yulanform.Text1.Text + vbCrLf
se(0) = &HA
ch = se(0)
For i = 1 To 10 '發送結束符
Yulanform.Text1.Text = Yulanform.Text1.Text + Format$(Hex$(ch), "@@ ")
MainForm.MSComm1.Output = se
Next i
Yulanform.Text1.Text = Yulanform.Text1.Text + " 十字節結束符0A" + vbCrLf
Yulanform.Text1.Text = Yulanform.Text1.Text + vbCrLf
MainForm.MSComm1.PortOpen = False
End If '對應本過程起始時刻的If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -