'读文本文件 Private Sub Command1_Click() Dim filenum As Integer Dim fileContents As String Dim fileInfo() As String Dim i As Integer
filenum = FreeFile Open "d:\aa.txt" For Binary As #filenum fileContents = Space(LOF(filenum)) Get #filenum, , fileContents Close filenum fileInfo = Split(fileContents, vbCrLf)
For i = 0 To UBound(fileInfo) - 1 debug.Print fileInfo(i) Next End Sub'读二进制文件 Private Sub Command1_Click() Dim n As Long Dim arrBytes() As Byte
'读出数据 Open "d:\draw.ico" For Binary As 1 n = LOF(1) ReDim arrBytes(1 To n) As Byte Get 1, , arrBytes Close 1
能否具體一點,小弟初學vb,很多地方不懂
Private Sub Command1_Click()
Dim filenum As Integer
Dim fileContents As String
Dim fileInfo() As String
Dim i As Integer
filenum = FreeFile
Open "d:\aa.txt" For Binary As #filenum
fileContents = Space(LOF(filenum))
Get #filenum, , fileContents
Close filenum
fileInfo = Split(fileContents, vbCrLf)
For i = 0 To UBound(fileInfo) - 1
debug.Print fileInfo(i)
Next
End Sub'读二进制文件
Private Sub Command1_Click()
Dim n As Long
Dim arrBytes() As Byte
'读出数据
Open "d:\draw.ico" For Binary As 1
n = LOF(1)
ReDim arrBytes(1 To n) As Byte
Get 1, , arrBytes
Close 1
End Sub