Converting String to Integer

Сonversation on different topics
Post Reply
Tusk24
Posts: 3
Joined: Tue May 15, 2018 3:35 pm

Converting String to Integer

Post by Tusk24 »

I am trying to write an expression to convert string fields into integers. The software that uses Stimulsoft collects a large amount of data via text boxes that are actually numbers and we'd like to be able to use Math equations (+, -, *, /) on those numbers.

From what I've gathered, the way to do this within Stimulsoft is to use int.Parse(string) or double.Parse(string) however when I do that via variable, I am getting an error from Stimulsoft stating: "Exception has been thrown by the target of an invocation"

If I do a test and put int.Parse("24") then 24 will come out as a number and int.Parse("24") / 3 will return 8. However anytime I bring a DB Table/Field into it, I get that error. I'm using the web version of Stimulsoft. Has anyone seen this issue or know of a potential resolution?

Thank you!
Tusk24
Posts: 3
Joined: Tue May 15, 2018 3:35 pm

Re: Converting String to Integer

Post by Tusk24 »

Update: I found that if I put my expression into my report as just a text field (expression) instead of as a variable, I can convert and compute the data (also using decimal instead of int)

{(decimal.Parse(Estim.User_Text2)*30) *(1-(decimal.Parse(Estim.User_Text2) / 100))}

This comes up with the number I need. However, I want to be able to use this number in another mathematical formula (which I thought would be done via variable, aka 100 - Variable1) but as soon as I add that line as a variable, I get errors. Any advice?
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: Converting String to Integer

Post by Lech Kulikowski »

Hello,

Please clarify which product and version are you use.
Also, please try to use the ReadOnly option for the variable. If the issue still present, please send us a sample report for analysis.

Thank you.
Post Reply