共用方式為


DataRecordset.GetDataRowIDs method (Visio)

會取得資料記錄集內所有資料列的識別碼陣列。

注意事項

This Visio object or member is available only to licensed users of Visio Professional 2013.

語法

表情GetDataRowIDs (CriteriaString)

一個回傳 DataRecordset 物件的表達式。

參數

名稱 必要/選用 資料類型 描述
CriteriaString 必要 字串 符合 Microsoft ActiveX Data Object (ADO) API 中針對設定 ADO.Filter 屬性所指定之指導方針的字串

傳回值

長 ()

註解

使用 GetDataRowIDs 方法取得資料記錄集中所有列的 ID 陣列,每列代表一個資料記錄。 GetDataRowIDs方法會將其參數當做準則字串,而此字串必須符合 ADO API 中針對設定 ADO.Filter 屬性所指定的指導方針。 您可以藉由指定適當的準則以及使用 AND 與 OR 運算子來分隔子句,以篩選資料記錄集內的資訊,而選擇性地只傳回某些資料記錄集資料列。 若不套用篩選條件 (也就是要取得所有資料列),請傳送空字串 ("")。

欲了解更多關於條件字串的資訊,請參閱 ADO 2.8 API 參考中的 篩選性質

範例

這本Microsoft Visual Basic for Applications (VBA) 巨集展示了如何使用 GetDataRowIDsGetRowData 方法回傳每一列的列 ID,然後取得指定資料集中每一列中每一欄的資料。 巨集會取得與目前文件相關的所有資料記錄集的計數,並取得最近新增紀錄的列資料。 它會遍歷資料集中的所有列,然後對每一列遍歷該列的所有欄位。 程式碼會在 [即時] 視窗中顯示傳回的資訊。

執行此巨集之前,必須先在目前文件中至少建立一個資料錄集。

請注意,巨集會將空字串傳至 GetDataRowIDs 方法,以略過篩選並取得記錄集中的所有資料列。 在您執行巨集之後,請注意,第一組顯示的資料 (對應於第一個資料列) 會包含資料記錄集中所有資料欄的標題。

Public Sub GetDataRowIDs_Example() 
 
     
    Dim vsoDataRecordset As Visio.DataRecordset 
    Dim intCount As Integer 
    Dim lngRowIDs() As Long 
    Dim lngRow As Long 
    Dim lngColumn As Long 
    Dim varRowData As Variant 
 
    'Get the count of all data recordsets in the current document. 
    intCount = ThisDocument.DataRecordsets.Count 
 
    Set vsoDataRecordset = ThisDocument.DataRecordsets(intCount) 
 
    'Get the row IDs of all the rows in the data recordset 
    lngRowIDs = vsoDataRecordset.GetDataRowIDs("") 
 
    'Iterate through all the records in the data recordset. 
    For lngRow = LBound(lngRowIDs) To UBound(lngRowIDs) + 1 
        varRowData = vsoDataRecordset.GetRowData(lngRow) 
 
        'Print a separator between rows 
        Debug.Print "------------------------------" 
 
       'Print the data stored in each column of a particular data row. 
        For lngColumn = LBound(varRowData) To UBound(varRowData) 
            Debug.Print varRowData(lngColumn) 
        Next lngColumn 
    Next lngRow 
 
End Sub

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應