Type safety in VB.NET and Visio cells

Started by Visisthebest, May 02, 2021, 09:12:29 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Visisthebest

In most VB.NET add-in code I am calculating with doubles.

When reading Cell.Result it is unclear which VisUnitCodes option makes sure that I am getting a double (not in any specific units, just a number from a shapesheet formula).

I could add a CDbl around it to force a double type whatever is returned:
https://docs.microsoft.com/en-us/office/vba/language/concepts/getting-started/type-conversion-functions

Yes the CDbl/CInt/etc they are also part of VB.NET not just VBA, but probably not the most elegant way to go about this. Maybe also has some side-effects I haven't considered. Type-safety is great but have to get used to it and VBA was quite a loose mistress in this regard ;)

(also miss not having to fully qualify all the enums, like the huge Visio.VisUniqueIDArgs.visGetOrMakeGUIDWithUndo, but alas getting so much back from VS2019 that the VBA IDE does not offer)

How do I make sure the VisUnitCodes setting leads to a double when reading Cell.Result? Thank you for your insights!
Visio 2021 Professional

Visisthebest

And for reading double values from Shape Data (also from VB.NET add-in), is this ok:

CDbl(MyShape.Cells("Prop.MyCustomProp").FormulaU)

Or is there a more elegant solution to ensure a double type (in no particular units) is returned?
Visio 2021 Professional

Nikolay


Visisthebest

Thank you Nikolay, life saver you are :) Microsoft has so poorly documented things from the VB.NET perspective everything is from the weakly typed VBA perspective.
Visio 2021 Professional

Visisthebest

On a related note, where can one nominate Nikolay for becoming a Microsoft Visio MVP? :D
Visio 2021 Professional

Nikolay

#5
Thank you, but I've been expelled already for doing nothing for one and a half year ;D
Looks like I'm just not up to the task of doing something on regular basis, like writing educational/promotional articles or videos, not to speak about conferencing.
I'm more at the level of writing the code for money rather than speaking/doing evangelist things actually.
BTW, there is no such thing as Visio MVP anymore, this nomination has been cancelled a few years ago (replaced by "Office and Services").

Other than that, currently I'm not really doing much for Visio (except supporting/improving my existing solutions of course).
Hopefully, we (me and the company I'm working with now) will put a decent product by summer to the Teams/SharePoint marketplace.
No replacement for Visio Online, but to some extent the drawing functionality will present there (good enough for our goals). It's based on mxgraph, not visio.

Doesn't it look somewhat similar to Visio (this is Teams tab)? Multi-user co-authoring (live), undo/redo are there! Will probably brag about it here as soon as we have it published :D



Visisthebest

#6
Might I add, you bringing MxGraph/diagrams.net functionality puts your Teams solution way ahead of the functionality of Visio web.

Hopefully this will stimulate Microsoft to up their investment in Visio significantly, both desktop and web, because with this release Microsoft is waaaaaaaaaaaaaaaay behind in web functionality within their own teams platform.

I also understand the Visio import/export is pretty decent.

Competition is a good thing, hopefully this helps the Visio team to get more funding to move Visio development faster than the glacial pace of the past years.
Visio 2021 Professional