?? module1.bas
字號(hào):
Attribute VB_Name = "Module1"
'接收模塊
Public bytReceiveByte() As Byte '接收到的字節(jié)
Public intReceiveLen As Integer '接收到的字節(jié)數(shù)
'顯示模塊
Public strAddress As String '地址信息
Public strHex As String '十六進(jìn)制編碼
Public strAscii As String 'ASCII碼
Public intHexWidth As Integer '顯示列數(shù)
Public intOriginX As Long '橫向原點(diǎn)(像素)
Public intOriginY As Integer '縱向原點(diǎn)(行)
Public intLine As Integer '總行數(shù)
'顯示常量
Public Const ChrWidth = 105 '單位寬度
Public Const ChrHeight = 2 * ChrWidth '單位高度
Public Const BorderWidth = 210 '預(yù)留邊界
Public Const LineMax = 16 '最大顯示行數(shù)
'**********************************
'輸入處理
'處理接收到的字節(jié)流,并保存在全局變量
'bytReceiveRyte()
'**********************************
Public Sub InputManage(bytInput() As Byte, intInputLenth As Integer)
Dim n As Integer '定義變量及初始化
ReDim Preserve bytReceiveByte(intReceiveLen + intInputLenth)
For n = 1 To intInputLenth Step 1
bytReceiveByte(intReceiveLen + n - 1) = bytInput(n - 1)
Next n
intReceiveLen = intReceiveLen + intInputLenth
End Sub
'為輸出準(zhǔn)備文本
'保存在全局變量
'strText
'strHex
'strAddress
'總行數(shù)保存在
'intLine
Public Sub GetDisplayText()
Dim n As Integer
Dim intValue As Integer
Dim intHighHex As Integer
Dim intLowHex As Integer
Dim strSingleChr As String * 1
Dim intAddress As Integer
Dim intAddressArray(8) As Integer
Dim intHighAddress As Integer
strAscii = "" '設(shè)置初值
strHex = ""
strAddress = ""
'*****************************************
'獲得16進(jìn)制碼和ASCII碼的字符串
'*****************************************
For n = 1 To intReceiveLen
intValue = bytReceiveByte(n - 1)
If intValue < 32 Or intValue > 128 Then '處理非法字符
strSingleChr = Chr(46) '對(duì)于不能顯示的ASCII碼,
Else '用"."表示
strSingleChr = Chr(intValue)
End If
strAscii = strAscii + strSingleChr
intHighHex = intValue \ 16
intLowHex = intValue - intHighHex * 16
If intHighHex < 10 Then
intHighHex = intHighHex + 48
Else
intHighHex = intHighHex + 55
End If
If intLowHex < 10 Then
intLowHex = intLowHex + 48
Else
intLowHex = intLowHex + 55
End If
strHex = strHex + " " + Chr$(intHighHex) + Chr$(intLowHex) + " "
If (n Mod intHexWidth) = 0 Then '設(shè)置換行
strAscii = strAscii + Chr$(13) + Chr$(10)
strHex = strHex + Chr$(13) + Chr$(10)
Else
End If
Next n
'***************************************
'獲得地址字符串
'***************************************
intLine = intReceiveLen \ intHexWidth
If (intReceiveLen - intHexWidth * intLine) > 0 Then
intLine = intLine + 1
End If
For n = 1 To intLine
intAddress = (n - 1) * intHexWidth
If intAdd48Chk = 1 Then
intHighAddress = 8
Else
intHighAddress = 4
End If
intAddressArray(0) = intAddress
For m = 1 To intHighAddress
intAddressArray(m) = intAddressArray(m - 1) \ 16
Next m
For m = 1 To intHighAddress
intAddressArray(m - 1) = intAddressArray(m - 1) - intAddressArray(m) * 16
Next m
For m = 1 To intHighAddress
If intAddressArray(intHighAddress - m) < 10 Then
intAddressArray(intHighAddress - m) = intAddressArray(intHighAddress - m) + Asc("0")
Else
intAddressArray(intHighAddress - m) = intAddressArray(intHighAddress - m) + Asc("A") - 10
End If
strAddress = strAddress + Chr$(intAddressArray(intHighAddress - m))
Next m
strAddress = strAddress + Chr$(13) + Chr$(10) '設(shè)置換行
Next n
'***************************************
End Sub
'*************************************
'顯示輸出
'*************************************
Public Sub display()
Dim intViewWidth As Long '橫向?qū)挾?像素)
Dim intViewLine As Integer '縱向?qū)挾?行)
Dim strDisplayAddress As String
Dim strDisplayHex As String
Dim strDisplayAscii As String
strDisplayAddress = ""
strDisplayHex = ""
strDisplayAscii = ""
Dim intStart As Integer
Dim intLenth As Integer
intStart = intOriginY * (intHexWidth + 2) + 1
intLenth = intViewLine * (intHexWidth + 2)
strDisplayAscii = Mid(strAscii, intStart, intLenth)
End Sub
'******************************************
'文本無變化的刷新
'******************************************
Public Sub ScrollRedisplay()
Call display
End Sub
'******************************************
'文本發(fā)生變化的刷新
'******************************************
Public Sub SlideRedisplay()
Call GetDisplayText
Call display
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -