数値計算の構文を教えてください。

UiPath Studio 2023.10.0 EnterPrise Licenseの初心者ユーザです。

3桁と2桁の整数値が並んでいます。

(イメージ)
100
90
20
80
600
70
50
40

下3桁と2桁の数値を組み合わせて2桁の数値を作成し、マイナス3した数値を作成したいが構文はどうなりますでしょうか。
例えば、100の場合は、10-3=7、70の場合は、07-3=4となります。
なお、最も小さい数は40のため、結果はマイナスにはなりません。

@gorby

You can use like this inside loop…

Say you arelooping on datatable with all these number

Then inside loop

Requiredvalue = Cont(currentRow("Column").ToString.PadLeft(3,CChar("0")).SubString(0,2)) - 3

Cheers

Thank you for your reply!
Are there any means without using datatable?

@gorby

Then formula works in anyway…without datatable also…

The idea is to just send each number once per iteration how ever it is…you can split the value and loop also

Cheers

Hi On my second thought, I noticed I can achieve my goal using simple Else If activity…
Pls let me know your comment.

Input data

100
90
20
80
600
70
50
40

Say, Input data is int_input, result is int_result,

If int_input.ToString.Length = 3

str_checkA= Left(int_input.ToString,2)

int_result = Cint(str_checkA)-3

Else If

str_checkA= "0" + Left(int_input.ToString,1)

int_result = Cint(str_checkA)-3

End If

Hi @gorby ,

You can use the following syntax:

Conversion. ToInt32 (item. ToString. Substring (item. ToString. Length -2.1))- 3

This extracts the last two digits from each number and converts them to integers, from which 3 is subtracted and the result is returned.

Thanks,

@gorby

You can do that also…

But I dont understand why do you want to attach a 0 at start as even if you attach…once converted to integer it will be ignored

Cheers

You may understand my intention if you read back my question at the top of this thread.

1 Like

@gorby

07-3 or 7-3 gives the same result

cheers

You may understand my intention if you read back my question at the top of this thread.

@gorby

I dont want to reiterate…but fine you got the answer Happy Automation

cheers

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.