Application.GUIDFromString 方法 (Access)

GUIDFromString 函數會將字串轉換為 guid,它是 Byte 類型的陣列。

語法

運算式GUIDFromString (字串)

expression 代表 Application 物件的變數。

參數

名稱 必要/選用 資料類型 描述
字串 必要 Variant 以字串形式評估為 GUID 的字串運算式。

傳回值

Variant

註解

Microsoft Access 資料庫引擎會儲存為 Byte 類型的陣列 Guid。 不過,Access 無法從表單或報表上的控制項傳回 位元組 資料。 若要從控制項傳回 GUID 的值,您必須將它轉換成字串。 若要將 GUID 轉換成字串,請使用 StringFromGUID 函式 。 若要將字串轉換為 guid、 使用 GUIDFromString 函數。

範例

下列範例會使用 GUIDFromString 函數可將字串轉換成 GUID。 複製 [Employees] 資料表中的字串格式儲存的 GUID 是字串。 欄位 s_GUID,是已複寫資料庫中每個複寫資料表中新增的隱藏欄位。

Sub CheckGUIDType() 
 
 Dim dbsConn As ADODB.Connection 
 Dim rstEmployees As ADODB.Recordset 
 
 ' Make a connection to the current database. 
 Set dbsConn = Application.CurrentProject.Connection 
 Set rstEmployees = New ADODB.Recordset 
 rstEmployees.Open "Employees", dbsConn, , , adCmdTable 
 
 ' Print the GUID to the immediate window. 
 Debug.Print rst!s_GUID 
 Debug.Print TypeName(rst!s_GUID) 
 Debug.Print TypeName(GuidFromString(rst!s_GUID)) 
 
 Set rstEmployees = Nothing 
 Set dbsConn = Nothing 
 
End Sub

支援和意見反應

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