1字节对齐————————分不够我加

来源:百度知道 编辑:UC知道 时间:2024/05/17 03:30:13
private type www
a as long
b as single
c as single
end type
dim nwww as www
nwww.a=23442
....
open "c:\s.dat" for random as #1
put #1,,nwww
close #1
怎么能按照1字节对齐写进去啊?????有人说用copymemory,那具体怎么弄啊 ????
vc中一字节对齐:#pragma pack(1),vb就是4字节对齐,好像不能自定义

你的问题在BASIC语言中,是属于定义结构体数据类型,对文件进行随机读写。
Option Explicit
Private Type www
a As Long
b As Single
c As Single
End Type
Dim FileLength
Dim nwww As www
Dim recordnum As Integer
Private Sub Command5_Click() ' 读记录
recordnum = InputBox("查询记录号", recordnum)
Open "c:\s.dat" For Random As #1 Len = 12
Get #1, recordnum, nwww
Close #1
Text5 = nwww.a & " " & nwww.b & " " & nwww.c

End Sub

Private Sub Command4_Click() ' 获取记录数
Open "c:\s.dat" For Random As #1 Len = 12
recordnum = LOF(1) \ Len(nwww)
Text5 = recordnum
Close #1
End Sub

Private Sub C