Division in UiPath / VB.net

I want to have a simple division formula with round integer result like “7 / 2 = 3”, and according to this article, it seems like we have to do it in “7 \ 2” in VB.

But this happens when I perform UiPath (and in Windows Explorer and some other apps) that when I type ‘’ it becomes ‘¥’ (I think it’s because I’m having the PC set in Japanese setting, all the folder path is becoming like “C:¥Users¥Administrators¥Desktop”. Any workaround to this?

Hello @whyyouandi just set your formula to clipboard with Set to Clipboard activity and pass hotkey Cntrl + v to paste your formula in desired fields. It is working for me.

You can use 7/2, rather than 7\2. Or you can use Decimal.Divide.

See attached.
division.xaml (6.6 KB)

3 Likes

Thank you @AkshaySandhu, sorry for the incomplete explanation.
I wanted to enter the formula into the Assign activity in UiPath (sweat).

Thank you @a-taniya, but I was looking for an integer for the result.
This below works but wondering if there is more straightforward way to do this.

Math.Round(Decimal.Divide(1/10))

How about Math.Round(1/10) ? I think it should work.

=edited=
Sorry I misunderstood your question.
In my case, backslash works perfect; 101\10 returnes 10.
I’m Japanese and of course my PC set in Japanese setting, so I guess there’s mistake on your flow.
Would it be possible to attach your workflow or screenshot?

Hi @whyyouandi,

If you cann’t use \ operator, try to use Math.Truncate method.

Regards,
Susana

Thank you @a-taniya, when I tried it in another PC, the operation still showed as “1¥10” when I typed “1\10” but it worked fine with no error, can’t comprehend why, but it just worked.

Thank you @Susana, was looking for a simpler workaround :wink:

The property send windows message of Type into activity must be enable. Try Disabling it, Other wise just write your text into a notepad and send hotkeys ctrl +x close application, go to the text input area of any application, send hotkeys ctrl+v.

Should you use below for a conditional output:
Variable: myNumber as Int32
divNumber as Int32

Output in decimals
Math.Truncate(Decimal.Divide(myNumber,divNumber))

Output as Integer
CInt(Math.Truncate(Decimal.Divide(myNumber,divNumber)))

Hope it helps the needy people.

1 Like