| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 563 人关注过本帖
标题:[讨论]请给它一个合理的解释
只看楼主 加入收藏
redice
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:902
专家分:0
注 册:2006-12-11
结帖率:72.73%
收藏
 问题点数:0 回复次数:2 
[讨论]请给它一个合理的解释

写东西时无意间发现了一个有趣的问题:

Private Sub Command1_Click()
'写入,然后读取
Dim cells(10) As Byte
filenum = FreeFile
Open "c:\ceshi1.txt" For Binary As filenum
Put filenum, , "我"
Get filenum, , cells
MsgBox cells(0) '理论上应该是206才对 为什么会是0呢?
Close
End Sub

Private Sub Command3_Click()
'先写入,然后关闭 再重新打开读取
Dim cells(10) As Byte
filenum = FreeFile
Open "c:\ceshi2.txt" For Binary As filenum
Put filenum, , "我"
Close filenum

filenum = FreeFile
Open "c:\ceshi2.txt" For Binary As filenum
Get filenum, , cells
MsgBox cells(0) '正确
Close filenum
End Sub

Private Sub Command2_Click()
'写入,然后读取(读取时指定位置)
Dim cells(10) As Byte
filenum = FreeFile
Open "c:\ceshi3.txt" For Binary As filenum
Put filenum, , "我"
Get filenum, 1, cells
MsgBox cells(0) '正确
Close
End Sub

事实就是这样 谁能提供点官方的解释(我查过了MSDN,好像没说这个问题)

[此贴子已经被作者于2007-5-9 13:53:01编辑过]

搜索更多相关主题的帖子: 合理 解释 
2007-05-09 13:52
huangwy
Rank: 1
等 级:新手上路
威 望:2
帖 子:297
专家分:0
注 册:2007-3-23
收藏
得分:0 
这很正常的
因为你写入东西以后,文件指针已经放在下一个位置
你读的是下一个位置的东西
2007-05-09 14:02
redice
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:902
专家分:0
注 册:2006-12-11
收藏
得分:0 
回复:(huangwy)这很正常的因为你写入东西以后,文件...

对 老兄你说的很对 我又犯傻了 哈哈 谢谢你呀

鲲鹏数据 - 专业Web数据采集服务提供者
http://www.
2007-05-09 14:15
快速回复:[讨论]请给它一个合理的解释
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018220 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved