GUIDFromString 函數(shù)

此頁(yè)沒(méi)有內(nèi)容條目
內(nèi)容

expandtri全部顯示

GUIDFromString 函數(shù)將字符串轉(zhuǎn)換為 GUID,其值為 Byte 數(shù)據(jù)類型的數(shù)組。

GUIDFromString(stringexpression)

GUIDFromString 函數(shù)具有以下參數(shù):

參數(shù)

說(shuō)明

stringexpression

對(duì)字符串形式的 GUID 進(jìn)行計(jì)算的字符串表達(dá)式

 

說(shuō)明

Microsoft Jet 數(shù)據(jù)庫(kù)引擎將 GUID 保存為 Byte 類型的數(shù)組。但是,Microsoft Access 不能從窗體報(bào)表上的控件中返回 Byte 數(shù)據(jù)。為了從控件中返回 GUID 的值,必須將它轉(zhuǎn)換為字符串。若要將 GUID 轉(zhuǎn)換為字符串,請(qǐng)使用 StringFromGUID 函數(shù)。若要將字符串轉(zhuǎn)換為 GUID,請(qǐng)使用 GUIDFromString 函數(shù)。

示例

下面的示例使用 GUIDFromString 函數(shù)將字符串轉(zhuǎn)換為 GUID。該字符串是以字符串形式存儲(chǔ)在同步復(fù)制的“雇員”表中的 GUID。字段 s_GUID 是隱藏字段,該字段將添加到同步復(fù)制數(shù)據(jù)庫(kù)中的每個(gè)同步復(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