📄 form1.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "Mscomm32.ocx"
Begin VB.Form Form1
BorderStyle = 0 'None
Caption = "Form1"
ClientHeight = 3405
ClientLeft = 0
ClientTop = 0
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3405
ScaleWidth = 4680
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text3
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 2400
TabIndex = 5
Text = "Text3"
Top = 360
Width = 1095
End
Begin MSCommLib.MSComm MSComm1
Left = 3720
Top = 2520
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
Begin VB.TextBox Text2
Height = 735
Left = 1080
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 4
Text = "Form1.frx":0000
Top = 1920
Width = 2055
End
Begin VB.CommandButton Command3
Caption = "Command3"
Height = 375
Left = 1560
TabIndex = 3
Top = 2880
Width = 975
End
Begin VB.CommandButton Command2
Caption = "Command2"
Height = 375
Left = 2160
TabIndex = 2
Top = 1320
Width = 975
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 375
Left = 1080
TabIndex = 1
Top = 1320
Width = 975
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 1080
TabIndex = 0
Text = "Text1"
Top = 360
Width = 975
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim zw(1 To 64) As Byte '64
Dim zw1(1 To 64) As Byte
Private Sub Command1_Click()
Text2.Text = ""
If Len(Text1.Text) <> 2 Then '2
MsgBox "输入汉字不足四个!"
Text1.Text = ""
Else
Dim ff As String
ff = CALL_LED(Text1.Text)
For I = 1 To 64 Step 1 '64
'If (Imod8) = 0 Then
Text2.Text = Text2.Text & " 0"
'End If
Text2.Text = Text2.Text & Hex(zw(I)) & "H"
Next I
End If
If Len(Text3.Text) <> 2 Then '2
MsgBox "输入汉字不足四个!"
Text3.Text = ""
Else
Dim ff1 As String
ff1 = CALL_LED1(Text3.Text)
For I = 1 To 64 Step 1 '64
'If (Imod8) = 0 Then
Text2.Text = Text2.Text & " 0"
'End If
Text2.Text = Text2.Text & Hex(zw1(I)) & "H"
Next I
End If
End Sub
Private Function CALL_LED(ledstring As String)
For j = 1 To 2 '2
AA = Hex(Asc(Mid(ledstring, j, 1)))
bb = (94 * (CLng("&H" & Mid(AA, 1, 2)) - &HA1) + (CLng("&H" & Mid(AA, 3, 2)) - &HA1)) * 32
For I = 1 To 32 Step 1
Open "C:\Documents and Settings\Administrator\桌面\点阵\HZK16" For Binary As #1
Get #1, bb + I, zw(32 * (j - 1) + I)
Close #1
Next I
Next j
End Function
Private Function CALL_LED1(ledstring As String)
For j = 1 To 2 '2
AA = Hex(Asc(Mid(ledstring, j, 1)))
bb = (94 * (CLng("&H" & Mid(AA, 1, 2)) - &HA1) + (CLng("&H" & Mid(AA, 3, 2)) - &HA1)) * 32
For I = 1 To 32 Step 1
Open "C:\Documents and Settings\Administrator\桌面\点阵\HZK16" For Binary As #1
Get #1, bb + I, zw1(32 * (j - 1) + I)
Close #1
Next I
Next j
End Function
Private Sub Command2_Click()
End
End Sub
Private Sub Command3_Click()
If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
MSComm1.PortOpen = True
MSComm1.Settings = "2400,n,8,1" '设波特率End Sub
MSComm1.Output = zw
MSComm1.Output = zw1
MSComm1.PortOpen = False
MsgBox "发送成功!!", vbOKOnly, "OK"
End Sub
Private Sub Form_Load()
Text1.FontSize = 16
Text1.Text = "清华"
Text3.FontSize = 16
Text3.Text = "大学"
Text2.Text = ""
'初始化串口
With MSComm1
.InputMode = 1 '设置接受数据的类型是二进制类型数据
.InputLen = 8 '一次性从接收缓冲区中读取所有数据(8个字节为一组!!)
.InBufferCount = 0 '清空接收缓冲区
.OutBufferCount = 0 '清空发送缓冲区
.SThreshold = 0 '不触发OnComm()事件
.RThreshold = 1 '接收1个字节数据触发OnComm()事件
.Settings = "2400,N,8,1"
.CommPort = 1
End With
End Sub
'Private Sub MsComm1_OnComm()
' Select Case MSComm1.CommEvent
' Case comEvReceive
' '这里就是接收数据后的处理,一般为:
' If CheckOK Then
' DoRight '正确数据处理
' Else
' DoWrong '出错数据处理
' End If
' Case Else
' End Select
' End Sub
' End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -