如何在 VB.Net 中使用 Page.getResults for Visio Automation

发布于 2024-11-14 02:51:20 字数 122 浏览 2 评论 0原文

将我的 VB 代码迁移到 VB.net 以实现 Visio Automation。我在 Page.GetResults 中收到错误 “指定的数组不是预期的类型”。 我猜错误与变体有关,但我无法解决。

感谢您的帮助

Migrating my VB code to VB.net for Visio Automation. I am getting error in Page.GetResults
"Specified array was not of the expected type".
I guess the Error is with Variant but i could not get resolved.

Thanks for any Help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一生独一 2024-11-21 02:51:20

如果您浏览此 Codeplex 项目的源代码,您将使用 Visual Studio 2010 查找 Page.GetResults 的 VB 示例。它位于名为“VS2010_VB_Samples.vb”的文件中,

我在下面包含了源代码。该示例旨在教授如何使用 API。它不是

    ' CREATE REQUEST
    Dim request = {
           New With { _
            Key .ID = CShort(shape.ID16), _
            Key .Section = CShort(IVisio.VisSectionIndices.visSectionObject), _
            Key .Row = CShort(IVisio.VisRowIndices.visRowXFormOut), _
            Key .Cell = CShort(IVisio.VisCellIndices.visXFormWidth), _
            Key .UnitCode = CShort(IVisio.VisUnitCodes.visNoCast) _
           }, 
          New With { _
            Key .ID = CShort(shape.ID16), _
            Key .Section = CShort(IVisio.VisSectionIndices.visSectionObject), _
            Key .Row = CShort(IVisio.VisRowIndices.visRowXFormOut), _
            Key .Cell = CShort(IVisio.VisCellIndices.visXFormHeight), _
            Key .UnitCode = CShort(IVisio.VisUnitCodes.visNoCast) _
            }
         }

    ' MAP THE REQUEST TO THE STRUCTURES VISIO EXPECTS
    Dim SID_SRCStream = New Short(request.Length * 4 - 1) {}
    Dim unitcodes = New Object(request.Length - 1) {}
    For i As Integer = 0 To request.Length - 1
        SID_SRCStream((i * 4) + 0) = request(i).ID
        SID_SRCStream((i * 4) + 1) = request(i).Section
        SID_SRCStream((i * 4) + 2) = request(i).Row
        SID_SRCStream((i * 4) + 3) = request(i).Cell
        unitcodes(i) = request(i).UnitCode
    Next

    ' EXECUTE THE REQUEST
    Dim flags = CShort(IVisio.VisGetSetArgs.visGetFloats)
    Dim results_sa As System.Array = Nothing
    page.GetResults(SID_SRCStream, flags, unitcodes, results_sa)

    ' MAP OUTPUT BACK TO SOMETHING USEFUL 
    Dim results_doubles = New Double(results_sa.Length - 1) {}
    results_sa.CopyTo(results_doubles, 0)

    ' DISPLAY THE INFORMATION
    shape.Text = String.Format("Results={0},{1}", results_doubles(0), results_doubles(1))

If you browse the sourcecode of this codeplex project you'll find a VB sample for Page.GetResults using Visual Studio 2010. It's in a file called "VS2010_VB_Samples.vb"

I've included the source code below. The example is meant to teach how to use the API. It is not

    ' CREATE REQUEST
    Dim request = {
           New With { _
            Key .ID = CShort(shape.ID16), _
            Key .Section = CShort(IVisio.VisSectionIndices.visSectionObject), _
            Key .Row = CShort(IVisio.VisRowIndices.visRowXFormOut), _
            Key .Cell = CShort(IVisio.VisCellIndices.visXFormWidth), _
            Key .UnitCode = CShort(IVisio.VisUnitCodes.visNoCast) _
           }, 
          New With { _
            Key .ID = CShort(shape.ID16), _
            Key .Section = CShort(IVisio.VisSectionIndices.visSectionObject), _
            Key .Row = CShort(IVisio.VisRowIndices.visRowXFormOut), _
            Key .Cell = CShort(IVisio.VisCellIndices.visXFormHeight), _
            Key .UnitCode = CShort(IVisio.VisUnitCodes.visNoCast) _
            }
         }

    ' MAP THE REQUEST TO THE STRUCTURES VISIO EXPECTS
    Dim SID_SRCStream = New Short(request.Length * 4 - 1) {}
    Dim unitcodes = New Object(request.Length - 1) {}
    For i As Integer = 0 To request.Length - 1
        SID_SRCStream((i * 4) + 0) = request(i).ID
        SID_SRCStream((i * 4) + 1) = request(i).Section
        SID_SRCStream((i * 4) + 2) = request(i).Row
        SID_SRCStream((i * 4) + 3) = request(i).Cell
        unitcodes(i) = request(i).UnitCode
    Next

    ' EXECUTE THE REQUEST
    Dim flags = CShort(IVisio.VisGetSetArgs.visGetFloats)
    Dim results_sa As System.Array = Nothing
    page.GetResults(SID_SRCStream, flags, unitcodes, results_sa)

    ' MAP OUTPUT BACK TO SOMETHING USEFUL 
    Dim results_doubles = New Double(results_sa.Length - 1) {}
    results_sa.CopyTo(results_doubles, 0)

    ' DISPLAY THE INFORMATION
    shape.Text = String.Format("Results={0},{1}", results_doubles(0), results_doubles(1))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文