English 中文(简体)
如何使用VB的植被。 维斯奥自动化网
原标题:how to use Page.getResults in VB.Net for Visio Automation

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.

感谢任何帮助

问题回答

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))




相关问题
Is Shared ReadOnly lazyloaded?

I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...

Entertaining a baby with VB.NET

I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

Hover tooltip on specific words in rich text box?

I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?

热门标签