Dim s As String
Dim filename As String
filename = shuxiang & xingzuo & ".txt"
Open filename For Input As #1
Do While Not EOF(1)
Line Input #1, s
Print s
Loop
Close #1
追加写文件
Dim i As Integer, n As Integer, a(6) As Integer
n = 6
Open "D:\1122.txt" For Append As #1
Randomize
For i = 1 To n
a(i) = Int(Rnd * 1000 + 1)
Print #1, a(i)
Next i
Close #1
覆盖写文件
Dim i As Integer, n As Integer, a(6) As Integer
n = 6
Open "D:\1122.txt" For output As #1
Randomize
For i = 1 To n
a(i) = Int(Rnd * 1000 + 1)
Print #1, a(i)
Next i
Close #1
把文件按二进制方式打开,然后把文件内容按字节存到一个动态字节数组里,最后只要对这个字节数组进行处理就行了。下面代码是把一个Mp3文件的开头100个字节提取并按16进制显示出来:
Private Sub Command1_Click()Dim b() As Byte, i As Long
Open "e:\tmp\1.mp3" For Binary As #1
b = InputB(100, #1)
Close #1
For i = 0 To UBound(b)
Print Right("0" & Hex(b(i)), 2) & " "
If i Mod 16 = 15 Then Print
Next
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)