[求助]关于在txt中存放数据的问题。。
模块Module1Type 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一个对象引用变量或包含对象引用的用户定义类型
请问错在哪里,应如何修改呢?谢谢了