共用方式為


DataRecordset.GetRowData method (Visio)

會取得指定之資料列中所有資料欄內的資料。

注意事項

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

語法

表情GetRowData (DataRowID)

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

參數

名稱 必要/選用 資料類型 描述
DataRowID 必要 Long 您要從中擷取資料之資料錄集內的資料列識別碼。

傳回值

變體 ()

註解

要取得資料記錄集中所有列的列 ID,請使用 GetDataRowIDs 方法。 請參閱本主題中的範例。

若為 DataRowID 參數傳送值為的資料列識別碼,GetRowData 方法就會傳回資料錄集內的資料欄名稱。 若傳送零以外的任何其他有效的資料列識別碼,GetRowData 方法就會傳回指定資料列中所有資料欄的值,而且順序會與方法在您傳送零時所傳回的資料欄名稱相同。

範例

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

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

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

Public Sub GetRowData_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 支援與意見反應