GUIDFromString 函數(shù)將字符串轉(zhuǎn)換為 GUID,其值為 Byte 數(shù)據(jù)類型的數(shù)組。
GUIDFromString(stringexpression)
GUIDFromString 函數(shù)具有以下參數(shù):
參數(shù) |
說明 |
stringexpression |
對字符串形式的 GUID 進行計算的字符串表達式。 |
Microsoft Jet 數(shù)據(jù)庫引擎將 GUID 保存為 Byte 類型的數(shù)組。但是,Microsoft Access 不能從窗體或報表上的控件中返回 Byte 數(shù)據(jù)。為了從控件中返回 GUID 的值,必須將它轉(zhuǎn)換為字符串。若要將 GUID 轉(zhuǎn)換為字符串,請使用 StringFromGUID 函數(shù)。若要將字符串轉(zhuǎn)換為 GUID,請使用 GUIDFromString 函數(shù)。
下面的示例使用 GUIDFromString 函數(shù)將字符串轉(zhuǎn)換為 GUID。該字符串是以字符串形式存儲在同步復(fù)制的“雇員”表中的 GUID。字段 s_GUID 是隱藏字段,該字段將添加到同步復(fù)制數(shù)據(jù)庫中的每個同步復(fù)制表中。
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