32位办公环境vba应用中uint64值的检索
Retrieving a uint64 value in a vba application running 32 bit office
我有一些vba编码,用于以二进制模式打开文件并将值存储到变量以供后续使用。我有关于文件结构的信息(我认为这些文件是用C或c++开发的程序创建的),所以知道文件中位置的偏移量,它的数据类型是Uint64(所以8字节)。
代码片段如下:
Dim strFile as String
Dim p as Long
strFile = "Testfile"
Open strFile For Binary As #1 ' Open file.
p = 1024 ' position of variable in file
Get 1, p, Value
变量'Value'需要声明为相当于Unit64的VBA,但由于我运行的是32位版本的office,我有点卡住了。我试图声明为Double,但这没有返回正确的值。不知道为什么。
如有任何建议,不胜感激
谢谢
整数数组可能是最好的选择。
Sub TestGetBin()
Dim DataByte(0 To 7) As Byte
Dim DataLong(0 To 1) As Long
Dim i As Long
' File contains "abcdefghijklmnopq"
Open "D:abc.txt" For Binary As #1
Get 1, 1, DataByte
Get 1, 1, DataLong
Debug.Print Hex(DataLong(0)), Hex(DataLong(1))
For i = 0 To 7
Debug.Print Hex(DataByte(i))
Next i
Close #1
End Sub
这个收益率
64636261 68676665
61
62
63
64
65
66
67
68
所以你可能会更喜欢字节数组(并从它创建你的数字)。
(嗯,这取决于号码是如何存储的。
相关文章:
- 使用VerQueryValue检索应用程序的文件描述
- 是否可以从格式字符串中检索"width"
- 使用 pqxx 将 std::vector 存储在 postgresql 中,并从数据库中检索它
- 如何在QByteArray中放置和检索位字段而不会感到痛苦?
- 如何在Qt中从数据库中检索二进制数据?
- 如何从C++代码中检索 QML 的文本字段中的文本?
- 从 opencv c++ 中的矢量中检索固定的帧数
- 如何在不等待检索的情况下获取C++中的内存位置?
- 如何在 QTreeWidget 中检索特定项目的 mimeData?
- C++从字符串中检索几行
- 在数据库中插入和检索矩阵
- 两个垫子的 OpenCV 数据是相同的,但使用 Mat::at 检索时的值已损坏
- 使用 const char* 键映射 C++ 检索空值
- 打印从SQLite3数据库检索的数据C++与命令行中相同的方式
- 如何检索指向在单独线程上运行的函数的移动指针?
- 如何检索 Steamwork SDK 的当前版本
- 通过 host() 从 af::array 检索数据会导致错误的数据
- 无法从类中检索值
- 初始化类中的指针数组,并在另一个类中检索它
- 32位办公环境vba应用中uint64值的检索