关于读取BMP文件的一个问题!(高手进)

crs96321 2004-02-03 01:56:43
我想读取一幅BMP文件。以前是用VC做的。
可以得到BMP文件每个字节的数据。

下面的程序原来是读取.TXT文件用的。我把文件名改成响应的BMP文件名,不知道为什么不好用了。

请帮助。先谢谢!

Dim filenum As Integer
Dim fileContents As String
Dim fileInfo() As String
Dim i As Integer
Dim strSourceFile As String
Dim str1() As Byte
' String

'strSourceFile = "G:\DLL\VB\1.txt"
strSourceFile = "G:\DLL\VB\03_12_25-09_43_06-AAUATJJAWIGC.bmp"
filenum = FreeFile

Open strSourceFile For Binary As #filenum

fileContents = Space(LOF(filenum))
Get #filenum, , fileContents
Close filenum
str1 = Split(fileContents, vbCrLf)

MsgBox str1(0)
...全文
129 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
northwolves 2004-02-03
  • 打赏
  • 举报
回复
Dim mybyte() As Byte
' Dim bmptext As String
Private Sub Command1_Click() '读文件

Open "c:\a.bmp" For Binary As 1
ReDim mybyte(LOF(1))
Get #1, , mybyte
Close 1
'bmptext = StrConv(mybyte, vbUnicode) ' to string
Label1.Caption = mybyte(1) ' show 2nd byte
End Sub

Private Sub Command2_Click() '写文件
Open "c:\back.bmp" For Binary As 1
Put #1, , mybyte
Close 1
End Sub

7,759

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧