从文件中删或取一结构体数据

来源:百度知道 编辑:UC知道 时间:2024/06/06 02:30:35
private type www
a as long
b as single
c as single
end type
一个文件中前面有12个字节是描述用的,后面都是像上面那样的结构体数据,前12字节我用不着,我怎么能直接读后面的结构体数据啊???还有就是怎么能把最后一个结构体数据删除啊???
dim nwww as www
Open "c:\s.dat" For Random As #1 Len = Len(www)
total = (LOF(1)-12) / Len(www)
For i = 1 To total
Seek #1, i
Get #1, , nwww

把最后一个结构体数据删除
Option Explicit
Private Type www
a As Long
b As Single
c As Single
End Type
Dim a_sj() As Byte
Dim i As Long
Dim FileLength
Dim nwww As www
Dim recordnum As Integer

Private Sub Command6_Click()
Open "c:\s.dat" For Binary As #1
FileLength = LOF(1) ' 取得文件长度。
Close #1
Text1 = FileLength
ReDim a_sj(1 To FileLength - 12)
Open "c:\s.dat" For Binary As #1
For i = 1 To FileLength - 12
Get #1, i, a_sj(i)
Next
Close #1
Kill "c:\s.dat"
Open "c:\s.dat" For Binary As #2
For i = 1 To FileLength - 12
Put #2, i, a_sj(i)
Next
Close #2
End Sub

这个问题不是那么简单的,说不清楚