共用方式為


Visio (的 Cell.ResultStrU 屬性)

會取得表示為通用字串之 ShapeSheet 儲存格的值。 唯讀。

語法

運算式ResultStrU (UnitsNameOrCode)

表達 會傳回 Cell 物件的運算式。

參數

名稱 必要/選用 資料類型 描述
UnitsNameOrCode 必要 Variant 在擷取值時所使用的單位。

傳回值

字串

註解

取得 ResultStrU 屬性與取得儲存格的 Result 屬性類似。 差別在於 ResultStrU 屬性是傳回字串當做儲存格的值,而 Result 屬性則傳回浮點數。

可以將 UnitsNameOrCode 指定為整數或字串值。 如果字串無效,則會產生錯誤。 例如,下列的陳述式全都會將 UnitsNameOrCode 設定為英吋。

stringReturned = Cell.ResultStrU (visInches)

stringReturned = Cell.ResultStrU (65)

stringReturned = Cell.ResultStrU (「in」) 其中 「in」 也可以是代表英吋的任何替代字串,例如 「inch」、「in.」 或 「intCounter」。

如需有效單位字串以及相對應之 Automation 常數 (整數值) 的完整清單,請參閱關於度量單位

代表單位的自動化常數是由 Visio 類型程式庫在成員 VisUnitCodes 中宣告

傳送零 (0) 就可以取得文字字串儲存格的值。

使用 ResultStrU 屬性在單位之間轉換。 例如,您可以用英吋取得值,然後再以公分取得相等的值。

ResultStrU 屬性對於使用儲存格值填入編輯方塊等控制項很有用。

注意事項

從 Microsoft Visio 2000 開始,您可以使用本機和通用名稱來參照 Visio 圖形、主圖形、檔、頁面、列、附加元件、儲存格、超連結、樣式、字型、主圖形快捷方式、UI 物件和圖層。 例如,當使用者為圖形命名時,使用者會指定本機名稱。 從 Microsoft Office Visio 2003 開始,ShapeSheet 試算表只會在儲存格公式和值中顯示通用名稱。 (在舊版中,使用者介面中看不到通用名稱。)

身為開發人員,如果您不希望每次將方案本土化時就要變更名稱,可以在程式中使用通用名稱。 請使用 ResultStr 屬性來取得表示為地區設定相關字串的物件值。 使用 ResultStrU 屬性來取得表示為通用字串的物件值。

範例

下列 Microsoft Visual Basic for Applications (VBA) 巨集會示範兩種不同的方式,使用 ResultStrU 屬性來取得包含圖形資料項目 (先前稱為自訂屬性) 之 ShapeSheet 儲存格的值。

若要執行這個巨集,請開啟空白的繪圖以及 Computers and Monitors (US Units) 樣板,然後插入包含標籤、文字方塊和清單方塊的使用者表單。 將清單方塊的寬度設定為 150。

注意事項

電腦和監視器 (US 單位) 樣板只能在Visio 專業版中使用。

 
Public Sub ResultStrU_Example()  
 
    Dim vsoStencil As Visio.Document  
    Dim vsoMaster As Visio.Master  
    Dim vsoPages As Visio.Pages  
    Dim vsoPage As Visio.Page  
    Dim vsoShape As Visio.Shape  
    Dim vsoCell As Visio.Cell  
    Dim intRows As Integer 
    Dim intCounter As Integer 
 
    'Get the Pages collection for the document.  
    'ThisDocument refers to the current document.  
    Set vsoPages = ThisDocument.Pages  
 
    'Get a reference to the first page of the Pages collection.  
    Set vsoPage = vsoPages(1)  
  
    'Get the Document object for the stencil.  
    Set vsoStencil = Documents("Comps_U.VSS") 
  
    'Get the Master object for the desktop PC shape.  
    Set vsoMaster = vsoStencil.Masters("PC")  
 
    'Drop the shape in the approximate middle of the page.  
    'Coordinates passed to the Drop method are always in inches.  
    'The Drop method returns a reference to the new shape object.  
    Set vsoShape = vsoPage.Drop(vsoMaster, 4.25, 5.5)  
 
    'This example shows two methods of extracting shape data 
    'The first method retrieves the value of a shape data item by name.  
    'Note that Prop.Manufacturer implies Prop.Manufacturer.Value.  
    Set vsoCell = vsoShape.Cells("Prop.Manufacturer")  
 
    'Get the cell value as a string  
    'and put it into the text box on the form.  
    UserForm1.TextBox1.Text = vsoCell.ResultStrU(Visio.visNone)  
 
    'Set the caption of the label.  
    UserForm1.Label1.Caption = "Prop.Manufacturer"  
 
    'The second method of accessing shape data uses  
    'section, row, cell. This method is best when you want  
    'to iterate through all the shape data.  
    intRows = vsoShape.RowCount(Visio.visSectionProp)  
 
    'Make sure the list box is cleared.  
    UserForm1.ListBox1.Clear  
 
    'Loop through all the rows and add the value of Prop.Manufacturer  
    'to the list box. Rows are numbered starting with 0.  
    For intCounter = 0 To intRows - 1  
        Set vsoCell = vsoShape.CellsSRC(Visio.visSectionProp, intCounter, visCustPropsValue)  
        UserForm1.ListBox1.AddItem vsoCell.LocalName & vbTab & _  
            vsoCell.ResultStrU(Visio.visNone)  
    Next intCounter  
 
    'Display the user form.  
    UserForm1.Show  
 
End Sub

支援和意見反應

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