DataRecordset.GetDataRowIDs 方法 (Visio)

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

注意事項

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

語法

運算式。 (CriteriaString) 的GetDataRowIDs

表達 會傳回 DataRecordset 物件的 運算式。

參數

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

傳回值

Long ()

註解

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

如需準則字串的詳細資訊,請參閱 ADO 2.8 API 參考中的 篩選屬性

範例

這個 Microsoft Visual Basic for Applications (VBA) 宏會示範如何使用 GetDataRowIDsGetRowData 方法傳回每個資料列的資料列識別碼,然後取得儲存在指定資料記錄集中每個資料列中每個資料行的資料。 宏會取得與目前檔相關聯之所有資料記錄集的計數,並取得最近加入之記錄集的資料列資料。 它會逐一查看資料記錄集中的所有資料列,然後針對每個資料列逐一查看該資料列中的所有資料行。 程式碼會在 [即時] 視窗中顯示傳回的資訊。

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

請注意,巨集會將空字串傳至 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 支援與意見反應