Cell.ResultStrU 属性 (Visio)

获取表示为通用字符串的 ShapeSheet 单元格的值。 此为只读属性。

语法

表达式ResultStrU (UnitsNameOrCode)

表达 返回 Cell 对象的表达式。

参数

名称 必需/可选 数据类型 说明
UnitsNameOrCode 必需 Variant 检索值时要使用的单位。

返回值

String

备注

获取 ResultStrU 属性类似于获取单元格的 Result 属性。 区别在于 ResultStrU 属性返回单元格值的字符串,而 Result 属性返回浮点数。

您可以将 UnitsNameOrCode 指定为整数或字符串值。 如果该字符串无效,将生成一个错误。 例如,下列语句全部将 UnitsNameOrCode 设置为英寸。

stringReturned = Cell.ResultStrU (visInches)

stringReturned = Cell.ResultStrU (65)

stringReturned = Cell.ResultStrU (“in”) 其中“in”也可以是表示英寸的任何备用字符串,例如“英寸”、“in.”或“intCounter”。

有关有效单位字符串以及对应的自动化常量(整型值)的完整列表,请参阅关于度量单位

用于表示单元的自动化常量由成员 VisUnitCodes 中的 Visio 类型库声明。

传递零 (0) 就可以获取文本字符串单元格的值。

使用 ResultStrU 属性在单位之间进行转换。 例如,您可以获取一个以英寸为单位的值,然后获取一个以厘米为单位的等效值。

ResultStrU 属性可用于使用单元格的值填充控件,例如编辑框。

注意

从 Microsoft Visio 2000 开始,您可以使用本地名称和通用名称来引用 Visio 形状、主控形状、文档、页面、行、加载项、单元格、超链接、样式、字体、主控形状快捷方式、UI 对象和图层。 例如,当用户命名形状时,用户将指定一个本地名称。 从 Microsoft Office Visio 2003 开始,ShapeSheet 电子表格在单元格公式和值中只显示通用名称。 (在以前的版本中,通用名称在用户界面中不可见。

) 作为开发人员,如果您不希望每次本地化解决方案时都更改名称,可以在程序中使用通用名称。 使用 ResultStr 属性获取对象的值,该值表示为特定于区域设置的字符串。 使用 ResultStrU 属性可获取表示为通用字符串的 对象的值。

示例

此 Microsoft Visual Basic for Applications (VBA) 宏显示了使用 ResultStrU 属性获取 ShapeSheet 单元格的值的两种不同方法,该单元格包含以前 (形状数据项,自定义属性) 。

要运行此宏,请打开一个空白绘图和“计算机和显示器(美制单位)”模具,然后插入一个包含标签、文本框和列表框的用户窗体。 将列表框的宽度设置为 150。

注意

美国单位) 模具 (计算机和监视器仅在Visio Professional中可用。

 
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 支持和反馈,获取有关如何接收支持和提供反馈的指南。