會將 Value 指定的位元組陣列轉換成 String。
語法
expression。
BinaryToString( _Value_ )
運算式 代表 PropertyAccessor 物件的變數。
參數
| 名稱 | 必要/選用 | 資料類型 | 描述 |
|---|---|---|---|
| 值 | 必要 | Variant | 表示要轉換的位元組陣列。 |
傳回值
代表轉換值的十六進位 字串 。
註解
如需使用 PropertyAccessor 物件時類型轉換的詳細資訊,請參閱 取得和設定屬性的最佳做法。
範例
Outlook 物件模式會公開項目物件的 EntryID 屬性,以便取得項目的項目 ID。 這個屬性是一個字串,代表該項目的 MAPI 屬性值 PR_ENTRYID。 除了 EntryID 屬性以外,您也可以使用 PropertyAccessor.GetProperty 方法來取得項目的 PR_ENTRYID 值,並使用 PropertyAccessor.BinaryToString,將該值轉換成字串。 此字串應符合相同項目的 EntryID 屬性值。 下列程式碼範例顯示 PropertyAccessor.GetProperty 方法所傳回的項目識別碼與 EntryID 屬性針對收件匣中每個項目所傳回的項目識別碼的等同性。
Sub TestEntryIDs()
Dim oMsg As Object
Dim oFolder As Outlook.Folder
Dim oItems As Outlook.Items
Dim oPA As Outlook.PropertyAccessor
Dim EntryID1 As String, EntryID2 As String, EntryIDProperty As String
'This is the MAPI property PR_ENTRYID referenced with its MAPI proptag namespace
EntryIDProperty = "http://schemas.microsoft.com/mapi/proptag/0x0FFF0102"
Set oFolder = Application.Session.GetDefaultFolder(olFolderInbox)
Set oItems = oFolder.Items
For Each oMsg In oItems
Set oPA = oMsg.PropertyAccessor
'First use the EntryID property of the item
EntryID1 = oMsg.EntryID
'Then use the PropertyAccessor
EntryID2 = oPA.BinaryToString(oPA.GetProperty(EntryIDProperty))
'The string equivalents of the two Entry IDs should be the same
If EntryID1 <> EntryID2 Then
Debug.Print "Error obtaining EntryID for " & oMsg.Subject
End If
Next
End Sub
另請參閱
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。