📄 lcd.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
Caption = "点阵字符型液晶显示编程"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin MSCommLib.MSComm MSComm1
Left = 840
Top = 2640
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
Begin VB.Frame Frame1
Caption = "请在此输入要显示的字符:"
Height = 2000
Left = 480
TabIndex = 0
Top = 600
Width = 3975
Begin VB.CommandButton Command1
Caption = "退出"
Height = 375
Index = 1
Left = 2520
TabIndex = 3
Top = 1320
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "发送数据"
Height = 375
Index = 0
Left = 480
TabIndex = 2
Top = 1320
Width = 1095
End
Begin VB.TextBox Text1
Height = 375
Left = 240
TabIndex = 1
Top = 480
Width = 3615
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim i As Integer '临时使用
Dim senddata(15) As Byte '发送数据数组
Private Sub Form_Load() '初始化
MSComm1.CommPort = 1 '第一串行口
If MSComm1.PortOpen = False Then
MSComm1.Settings = "9600,n,8,1" '定义传输格式
MSComm1.InputMode = comInputModeBinary '数据格式为二进制
MSComm1.RThreshold = 0 '收到数不引发OnComm事件
MSComm1.InputLen = 0 '一次读缓冲区全部数据
MSComm1.PortOpen = True '打开串行口
End If
MSComm1.InBufferCount = 0 '输入缓冲计数为0
Text1.MaxLength = 16 '输入框限制16个字符
End Sub
Private Sub Command1_click(Index As Integer)
Select Case Index
Case 0 '单击“发送数据”命令按钮
For i = 1 To Len(Text1.Text) '给senddata数组赋值
senddata(i - 1) = Asc(Mid(Text1.Text, i, 1)) '把Text1给senddata
Next i
If Len(Text1.Text) < 16 Then '不足部分补空格
For i = Len(Text1.Text) To 15
senddata(i) = 32
Next i
End If
MSComm1.Output = senddata '发送出去
MSComm1.InBufferCount = 0 '输入缓冲计数为0
Case 1 '单击“退出”命令按钮
MSComm1.PortOpen = False '关闭
End
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -