Private Type coustomer
 num As Integer
 name As String * 8
 city As String * 10
 phonee As String * 15
 lasttouch As Data
 End Type
Private no As Integer
Private str1 As coustomer 
 
Private Sub Command1_Click()
If Command1.Caption = "读记录" Then
  Get #3, Val(Text6.Text), str1
 Text1.Text = str1.num
Text2.Text = str1.name
Text3.Text = str1.city
Text4.Text = str1.phone
Text5.Text = str1.lasttouch
Else
str1.num = Text1.Text
str1.name = Text2.Text
str1.city = Text3.Text
str1.phone = Text4.Text
str1.lasttouch = Text5.Text
Put #3, Val(Text6.Text), str1
End If  
End SubPrivate Sub Command2_Click()
If Val(Text6.Text) > 1 Then
 Text6.Text = Val(Text6.Text) - 1
 Get #3, Val(Text6.Text), str1
 Text1.Text = str1.num
Text2.Text = str1.name
Text3.Text = str1.city
Text4.Text = str1.phone
Text5.Text = str1.lasttouch
End If
End SubPrivate Sub Command3_Click()
 If Not EOF(3) Then
 Text6.Text = Val(Text6.Text) + 1
Get #3, Val(Text6.Text), str1
  Text1.Text = str1.num
Text2.Text = str1.name
Text3.Text = str1.city
Text4.Text = str1.phone
Text5.Text = str1.lasttouch
Else
  Text6.Text = Val(Text6.Text) - 1
End IfEnd SubPrivate Sub Command5_Click()
If no = 0 Then
  no = Val(Text6.Text)
  Command5.Caption = "返回"
  Else
      Text6.Text = no
      Get #3, Val(Text6.Text), str1
      
      Text1.Text = str1.num
Text2.Text = str1.name
Text3.Text = str1.city
Text4.Text = str1.phone
Text5.Text = str1.lasttouch
  Command5.Caption = "写书签"
  no = 0
  End If
End SubPrivate Sub Form_Load()
no = 0
Text6.Text = 1
Open "d:\kh\coustomer.dat" For Random As #3 Len = Len(str1)
Get #3, 1, str1Text1.Text = str1.num
Text2.Text = str1.name
Text3.Text = str1.city
Text4.Text = str1.phone
Text5.Text = str1.lasttouch
End SubPrivate Sub Option1_Click()
If Option1.Value = True Then
 Command1.Caption = "读记录"
End IfEnd SubPrivate Sub Option2_Click()
If Option2.Value = True Then
   Command1.Caption = "写记录"
End IfEnd Sub运行了以后就会出现“不能get或put 一个对象引用变量或包含对象引用的用户定义类型”
这是什么意思啊  ??请教!!!

解决方案 »

  1.   

    Private Type coustomer 
    num As Integer 
    name As String * 8 
    city As String * 10 
    phonee As String * 15 
    lasttouch As Data 
    End Type 
    Private no As Integer 
    Private str1 As coustomer 不能 Get 或 Put 对象引用变量,或含有对象引用的自定义类型变量
       对象引用是临时的,并且很容易在关闭与打开文件间变成无效的。这个错误的起因与解决方法如下所示: 在 Get 或 Put 语句中的变量包含,或被声明为包含一个对象的引用。 
    假如此变量是一个对象的引用,便不能在 Get 和 Put 语句使用它。如果要将对象的属性值放入文件,每个属性必须被个别地指定。Get 或 Put 语句中的用户定义类型变量包含的元素为对象引用。 
    假如变量的 Type 语句包含的元素代表一个对象(例如,它在一个类模块中被定义,具有 Object 数据类型,是一个窗体或控件等等),从定义中将它删除,或者定义一个为了 Get 和 Put 语句使用的新类型,在该类型的定义中没有 Object 类型的元素。假如有 Variant 类型的用户自定义类型的元素,请确定没有对象引用赋予该元素。 Variant 可以接受这样的赋值式,但假如其用户自定义类型在 Get 或 Put 中被使用,将会造成这个错误。请注意,您可以使用 Input #、Line Input #、Print # 或 Write #,将一个对象的缺省属性写入磁盘。详细信息,请先选取有疑问的项目,然后按下 F1 键 。
      

  2.   

    楼主是不是这句写错了?
    lasttouch As Data
    如果我没有猜错的话,你好像表示最后接触时间,应该是Date类型吧?