fixing some old code

Started by perry59, March 13, 2024, 06:45:46 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

perry59

I am working on some old code written by someone else, may have originated in vba but I'm putting it in vb.net. there are several places generating errors and I believe I have corrected them but would like input from others.
Original fragment:

With winObj.Selection(1)
            .Cells(PX) = dblLeft + (.Cells(PX))
            .Cells(PY) = dblBottom - (.Cells(PY))
            .Name = NT
      End With


PX and PY are constants evaluating to "PinX" and "PinY", dblleft and dblbottom are floating point numbers

Here is what I have converted it to, which seems to work ok

With winObj.Selection(1)
            .Cells(PX).FormulaForceU = Convert.ToString(dblLeft + (.Cells(PX).Result(Visio.VisUnitCodes.visNoCast)))
            .Cells(PY).FormulaForceU = Convert.ToString(dblBottom - (.Cells(PY)).Result(Visio.VisUnitCodes.visNoCast)))
            .Name = NT
        End With


does this look right? is there a better way to achieve the desired results?
thanks for any tips
what, me worry?

Yacine

I usually use ResultIU (=internal units) when dealing with numbers. Don't know how visNoCast behaves.
Yacine