📄 module1.bas
字号:
Attribute VB_Name = "Module1"
Dim data() As Byte
Dim rom(255) As Byte
Dim fileHandle As Integer
Dim length As Long
Dim position As Long
Public Sub GetFileData(fileName As String)
fileHandle = 1
Open fileName For Binary As #fileHandle
length = LOF(fileHandle)
ReDim data(length)
Get #fileHandle, , data
Close #fileHandle
position = 0
End Sub
Public Sub SetCommProperty(comm As MSComm)
If comm.PortOpen = True Then comm.PortOpen = False
comm.CommPort = 1
comm.Settings = "115200, n, 8, 1"
comm.PortOpen = True
End Sub
Public Function SendData(comm As MSComm, procBar As ProgressBar, label As label) As Boolean
Dim d() As Byte
ReDim d(8) As Byte
Dim percent As Integer
d(0) = data(position)
If position + 1 < length - 1 Then d(1) = data(position + 1)
If position + 1 < length - 1 Then d(2) = data(position + 2)
If position + 1 < length - 1 Then d(3) = data(position + 3)
If position + 1 < length - 1 Then d(4) = data(position + 4)
If position + 1 < length - 1 Then d(5) = data(position + 5)
If position + 1 < length - 1 Then d(6) = data(position + 6)
If position + 1 < length - 1 Then d(7) = data(position + 7)
comm.Output = d
position = position + 8
If position + 8 >= length Then position = length - 1
percent = CInt(CSng(position) / CSng(length) * 100)
procBar.Value = percent
label.Caption = "已完成" + CStr(percent) + "%"
If position < length - 1 Then
SendData = True
Else
position = 0
SendData = False
End If
End Function
Public Sub Fbc()
Dim j As Long
For j = 0 To length - 1
data(j) = data(j) / 2
data(j) = rom(data(j))
Next j
End Sub
Public Sub InitRow()
Dim i As Integer
For i = 0 To 127
rom(i) = 127 - i
Next i
For i = 128 To 255
rom(i) = rom(255 - i) + 128
Next i
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -