求助,用VB读取文件像winhex一样
怎么能像winhex一样16进制读取文件,还可以把偏移地址上的数据输出到textbox里,如偏移地址00001208上的值输出。
'工具显示16进制代码
With Form1.Text3
Dim txj As String
Dim txj2 As String
Dim txj3 As String
Dim txp As Boolean
Dim txj4 As Integer
Dim txk(1) As Byte
.Text = "加密结果" & vbCrLf & " 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"
For i = 0 To optr - 1
'.Text =.Text & vbcrlf &
txj = Hex(pout(i))
If Len(txj) = 1 Then txj = "0" & txj
txj2 = txj2 & " " & txj
If pout(i) < 128 Then
If pout(i) >= 32 Then
txj3 = txj3 & Chr(pout(i))
Else
txj3 = txj3 & "."
End If
Else
If Not txp Then
txk(1) = pout(i)
txk(0) = pout(i + 1)
CopyMemory txj4, txk(0), 2
txj3 = txj3 & Chr(txj4)
txp = True
Else
txp = False
End If
End If
If (i + 1) Mod 16 = 0 Then
txj = "0" & i \ 16
txj = String(4 - Len(txj), "0") & txj
.Text = .Text & vbCrLf & txj & " " & txj2 & " " & txj3
txj2 = ""
txj3 = ""
End If
Next i
txj = "0" & i \ 16
txj = String(4 - Len(txj), "0") & txj
.Text = .Text & vbCrLf & txj & " " & txj2 & Space(48 - Len(txj2)) & " " & txj3
End With
'工具输出结束
以前写的 一个十六进制显示的例子,你参考一下吧。
VB6 读写文件,三种文件,顺序文件,随机文件,二进制文件。
二进制文件就是了你所说的 十六进制读文件。