- 初中三年级
- 1797351
- 366
- 0
- 58 朵
- 775 个
- 348 个
- 700
- 2013-05-10
|
4#
t
T
发表于 2025-01-26 09:15
|
|只看该用户
- // 定义记事本文件的路径
- Dim filePath = "C:\Test\test.txt"
- // 检查文件是否存在
- If Dir(filePath) = "" Then
- MessageBox "指定的文件不存在,请检查路径!"
- ExitScript
- End If
- // 读取文件的所有行
- Dim lines
- Call FileReadLines(filePath, lines)
- // 检查文件是否为空
- If UBound(lines) < 0 Then
- MessageBox "文件为空,没有内容可读取!"
- ExitScript
- End If
- // 获取第一行内容
- Dim firstLine = lines(0)
- // 输入第一行内容
- SayString firstLine
- // 删除第一行并重新写入文件
- Dim newLines
- For i = 1 To UBound(lines)
- ReDim Preserve newLines(i - 1)
- newLines(i - 1) = lines(i)
- Next
- // 清空原文件内容
- Call FileDelete(filePath)
- // 将新内容写入文件
- For Each line In newLines
- Call FileWrite(filePath, line)
- Next
复制代码差不多这样吧, 你修改一下
|