- 1
- 0
- 约5.94千字
- 约 4页
- 2022-07-26 发布于福建
- 举报
************************************************* 文件统计替换字符
Private Sub Form_Load()
On Error Resume Next
Dim Handle As Integer, Filetext As String
Handle = FreeFile
Open C:\MYDIR\DATA.TXT For Binary As #Handle ’打开一个文件(二进制形式打开)
Filetext = Space(LOF(Handle)) ‘
Get #Handle, , Filetext
Close #Handle
读取文件
Dim A As Long, B As Long
A = FileLen(C:\MYDIR\DATA.TXT)
B = Len(Replace(Filetext, $, ))
计算差值
Handle = FreeFile
Open C:\Mydir\res.txt For Output As #Handle
Print #Handle, A - B
Close #Handle
保存
End Sub
*************************************** 读取文件内容到字符串变量
Private Sub Command1_Click()
Dim s As String
Open c:sql.txt For Binary As #1
s=space(lof(1))
get #1,1, s
Close #1
Debug.Print s
end sub
******************************************** 把一个文件复制
dim buf as string
Open C:\test.txt for Input as #1
line input#1,buf
当用过后指针本来就是自动到下一行的 !你还可以用二进制方式打开文件并自己定义
读入或写入多少 !!
dim buf()as byte
Open C:\test.exe for binary as #1
redim buf(1 to lof(1))
get#1,,buf
close #1
open D:\test.exe for binary as #1
put #1,,buf
close#1
这个程序实现把 C:\test.exe 复制到 D 盘
********************************************* 寻找字符
1. Private Sub Command1_Click()
2. Dim i As Long
3. Dim b As Byte
4.
5. Open c:\demo.dat For Binary As #1
6.
7. Do While Not EOF(1)
8. i = i + 1
9. Get #1, , b
10. If b = Asc(A) Then Print i
11. Loop
12. Close
13. End Sub
***************************************** 直接读文件最后一行
Private Sub Comma
您可能关注的文档
最近下载
- 全国大学生数学建模竞赛b题全国优秀论文 .pdf VIP
- 2026浙美版美术八年级下册第二单元第3课《独特的视角》课件.pptx
- 2023年全国大学生数学建模竞赛题目B:.docx VIP
- 2020年美国大学生数学建模竞赛题目E--淹没在塑料中范文五篇(含源代码).pdf VIP
- 2021年全国大学生数学建模竞赛题目E:中药材的鉴别优秀论文范例两篇(含源代码).pdf VIP
- 2025-《期货基础知识》教材精讲班.pdf VIP
- 农贸市场改造升级策略及实施方案.docx VIP
- 高中英语单词表(全)(最新完整版)11802.xls VIP
- 比亚迪E5汽车驱动电机异响故障检修方案设计.docx VIP
- 西方近现代美术 课件 2026浙美版美术八年级下册.pptx
原创力文档

文档评论(0)