VB6.0中二进制访问代码怎样写?保存时用结构体代码怎样写?
PrivateTypeFabricNameAsString'名称NoAsString'编号TjAsDouble'经纱号数TwAsDouble'纬纱号数LAsDouble'...
Private Type Fabric
Name As String '名称
No As String '编号
Tj As Double '经纱号数
Tw As Double '纬纱号数
L As Double '织物幅宽
Pj As Double '经纱密度
Pw As Double '纬纱密度
Aj As Double '经纱缩率
Aw As Double '纬纱缩率
Ej As Double '经向紧度
Ew As Double '纬向紧度
Ez As Double '总紧度
Gj As Double '经纱重量
Gw As Double '纬纱重量
Gz As Double '总重量
End Type
Private Fab As Fabric
'保存
Private Sub Command2_Click()
CommonDialog1.InitDir = "c:\" '路径
CommonDialog1.FileName = "fab.txt" '名称
CommonDialog1.Filter = "fab files(*.txt)/*.txt/all files(*.*)/*.*" '拓展名
CommonDialog1.ShowSave '保存
Open CommonDialog1.FileName For Output As #1
Print #1, Text1.Text '不会用结构体表示
Print #1, Text2.Text
Print #1, Text3.Text
Print #1, Text4.Text
Print #1, Text5.Text
Print #1, Text6.Text
Print #1, Text7.Text
Print #1, Text8.Text
Print #1, Text9.Text
Close #1
End Sub
'打开
Private Sub Command3_Click()
Open "c:\fab.txt" For Binary As #1
'这里该怎样写?
Close #1
End Sub 展开
Name As String '名称
No As String '编号
Tj As Double '经纱号数
Tw As Double '纬纱号数
L As Double '织物幅宽
Pj As Double '经纱密度
Pw As Double '纬纱密度
Aj As Double '经纱缩率
Aw As Double '纬纱缩率
Ej As Double '经向紧度
Ew As Double '纬向紧度
Ez As Double '总紧度
Gj As Double '经纱重量
Gw As Double '纬纱重量
Gz As Double '总重量
End Type
Private Fab As Fabric
'保存
Private Sub Command2_Click()
CommonDialog1.InitDir = "c:\" '路径
CommonDialog1.FileName = "fab.txt" '名称
CommonDialog1.Filter = "fab files(*.txt)/*.txt/all files(*.*)/*.*" '拓展名
CommonDialog1.ShowSave '保存
Open CommonDialog1.FileName For Output As #1
Print #1, Text1.Text '不会用结构体表示
Print #1, Text2.Text
Print #1, Text3.Text
Print #1, Text4.Text
Print #1, Text5.Text
Print #1, Text6.Text
Print #1, Text7.Text
Print #1, Text8.Text
Print #1, Text9.Text
Close #1
End Sub
'打开
Private Sub Command3_Click()
Open "c:\fab.txt" For Binary As #1
'这里该怎样写?
Close #1
End Sub 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询