标题:[求助]关于在txt中存放数据的问题。。
只看楼主
aasd5
Rank: 1
等 级:新手上路
帖 子:57
专家分:0
注 册:2006-4-24
 问题点数:0 回复次数:3 
[求助]关于在txt中存放数据的问题。。
模块Module1
Type guest
strName As String * 8
blnSex As Boolean
byaAge As Byte
strCompany As String * 40
strTitle As String * 20
strRoom As String * 4
dtmIn As Data
dtmOut As Data
blnIsIn As Boolean
End Type
五个窗体
在一个窗体中
Private Sub cmdAdd_Click()
Dim NewGuest As guest
Dim int1 As Integer
If Len(Trim(CStr(txtName.Text))) = 0 Then
MsgBox ("必须输入姓名")
Exit Sub
End If
NewGuest.blnIsIn = True
NewGuest.blnSex = optMale.Value
NewGuest.byaAge = CInt(txtAge.Text)
NewGuest.dtmIn = Now
NewGuest.strCompany = txtCompany.Text
NewGuest.strName = txtName.Text
NewGuest.strTitle = cboTitle.Text
NewGuest.strRoom = cboRoom.Text
If Dir(strGuestNum) = "" Then
int1 = 0
Else
Open strGuestNum For Input As 1
Input #1, int1
Close 1
End If
Open strGuestNum For Output As 1
Write #1, int1 + 1
Close 1
Open strGuestData For Random As 1 Len = Len(NewGuest)
Put 1, int1 + 1, NewGuest
Close 1
For int1 = 0 To cboTitle.ListCount - 1
If Trim(cboTitle.Text) = Trim(cboTitle.List(int1)) Then
Exit For
End If
Next
If int1 = cboTitle.ListCount Then
Open strTitle For Append As 1
cboTitle.AddItem Trim(cboTitle.Text)
Write #1, Trim(cboRoom.Text)
Close 1
End If
ClearControl
End Sub

运行时出错
行:Open strGuestData For Random As 1 Len = Len(NewGuest)
Put 1, int1 + 1, NewGuest

编译错误:
不能Get或Put一个对象引用变量或包含对象引用的用户定义类型

请问错在哪里,应如何修改呢?谢谢了
搜索更多相关主题的帖子: txt 数据 
2007-11-11 18:11
刨子头
Rank: 1
等 级:新手上路
威 望:1
帖 子:319
专家分:0
注 册:2007-9-24
得分:0 
有类似的问题“随机存取文件”,站内搜索
2007-11-11 18:33
三断笛
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:31
帖 子:1621
专家分:1617
注 册:2007-5-24
得分:0 
用数据库吧
2007-11-12 10:33
aasd5
Rank: 1
等 级:新手上路
帖 子:57
专家分:0
注 册:2006-4-24
得分:0 

额,谢谢楼上的两位。。。我试试。。


2007-11-12 10:43



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-185289-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.140896 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved