Operating with decimals
5 years

I can not do the program well to add a decimal integer.

I have a variable "distance" made ​​with two points with the module "display_line". When the program runs this variable gives me incremental values ​​as 6.355 / 6.489 / 6.590 / 6.654 ............

I would like to add the difference in decimal value of each for a total distance "Total distance". Eg
(6.489 to 6.355) = 0.134
(6.590 to 6.489) = 0.101
(6.654 to 6.590) = 0.064

Therefore, the total distance "Total distance" is 0.134 + 0.101 + 0.064 = 0.299 m.

This is the part of my VBScript program where I try to figure this.

i = GetVariable("distance")

decimal=Mid(CStr(3/2), 2, 1)

SetVariable "Total disatance",add

Thanks so much.
Steven from United States  [1401 posts] 5 years
I'm not sure that will get you want you are asking for. If you are trying to convert a comma into a period due to your international usage you may just want to change the

Windows Start Button->Control Panel->Region and Language->Additional Settings->Change Decimal Symbol to a period.

If you want to add the changes from the distance you start with a set base number and then check the difference to that number as apposed to adding each time it changes ... something like:

if GetVariable("Start_Distance") = 0 then
  SetVariable "Start_Distance", GetVariable("distance")
end if

SetVariable "Total_Distance", GetVariable("distance") - GetVariable("Start_Distance")

and that should do it.

Anonymous 5 years
Hi Steven.

For example, number 4,589

I need a function in VBscript I separate the decimal integer. I need this decimal 0,589.

Steven from United States  [1401 posts] 5 years

result = 4.589 - CInt(4.589)

should do that.


This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index