共用方式為


Visio (的 Cell.ResultStr 屬性)

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

語法

運算式ResultStr (UnitsNameOrCode)

表達 代表 Cell 物件的變數。

參數

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

傳回值

字串

註解

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

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

stringReturned = Cell.ResultStr (visInches)

stringReturned = Cell.ResultStr (65)

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

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

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

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

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

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

範例

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

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

注意事項

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

 
Public Sub ResultStr_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.ResultStr(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.ResultStr(Visio.visNone) 
 Next intCounter 
 
 'Display the user form. 
 UserForm1.Show 
 
End Sub

支援和意見反應

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