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

📄 led点阵式显示屏上位机程序.txt

📁 随着科学技术的发展
💻 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 + -