谢谢你们的帮助
以下是我的结论:
- Public Sub jbKeyNotesFormRefresh()
- Dim KeynoteDict As AcadDictionary, KeynoteXRecord As AcadXRecord
- Dim XRecordDataType As Variant, XRecordData As Variant
- Dim ArraySize As Long, iCount As Long
- Dim DataType As Integer, Data As String, msg As String
- Dim file As String, str As String
- ' Unique identifiers to distinguish this XRecordData from other XRecordData
- Const TYPE_STRING = 300
- Const TAG_DICTIONARY_NAME = "JB_KEYNOTE"
- Const TAG_XRECORD_NAME = "JB_KEYNOTE_FILE"
-
- ' Connect to the dictionary in which to store the XRecord
- On Error GoTo ERR
- Set KeynoteDict = ThisDrawing.Dictionaries(TAG_DICTIONARY_NAME)
- Set KeynoteXRecord = KeynoteDict.GetObject(TAG_XRECORD_NAME)
- On Error GoTo 0
-
- ' Get current XRecordData
- KeynoteXRecord.GetXRecordData XRecordDataType, XRecordData
-
- ' If there is no array yet then create one
- If VarType(XRecordDataType) And vbArray = vbArray Then
- ArraySize = UBound(XRecordDataType) + 1 ' Get the size of the data elements returned
- ArraySize = ArraySize + 1 ' Increase to hold new data
-
- ReDim Preserve XRecordDataType(0 To ArraySize)
- ReDim Preserve XRecordData(0 To ArraySize)
- Else
- ArraySize = 0
- ReDim XRecordDataType(0 To ArraySize) As Integer
- ReDim XRecordData(0 To ArraySize) As Variant
- End If
-
- ' Read back all XRecordData entries
- KeynoteXRecord.GetXRecordData XRecordDataType, XRecordData
- ArraySize = UBound(XRecordDataType)
-
- ' Retrieve and display stored XRecordData
- For iCount = 0 To ArraySize
- ' Get information for this element
- DataType = XRecordDataType(iCount)
- Data = XRecordData(iCount)
-
- If DataType = TYPE_STRING Then
- file = Data
- End If
- Next
-
-
- KeyNotes.ListBox2.Clear
- On Error GoTo ErrMessage
- If Not file = "" Then
- Open file For Input As #1
- Do While Not EOF(1)
- Input #1, str
- KeyNotes.ListBox2.AddItem (str)
- Loop
- Close #1
- End If
- ErrMessage:
- Close #1
- Exit Sub
-
- Exit Sub
- ERR:
- KeyNotes.ListBox2.Clear
- End Sub
我在表单刷新代码中包含了字典内容,因为我不知道如何在函数之间传递变量
jb |