Hello everyone and thank you in advance if you can help.
Introduction: I am super beginner, so I hope I won't annoy anyone. Furthermore I checked the forum and the web for a solution, but I cannot have it working.
Situation: I am getting some data from a COM1 port (on the other side there is a weight scale) and putting the data into a variable. Starting from this variable, which is filled by the COM port, I use a function to extract the net weight (i.e. I extract characters from position 3 to 10 and I get a value which looks like 10.450 that I read 10kg and 450gr ).
Problem: as soon as I just look at the number everything is fine, however when I try to use this value to do some math (i.e. weight * price) the comma is not considered at all. Therefore if I use a price of 1€/Kg I get 10450€ instead of 10,45€ . I think the problem is the value being processed as a string and not as a number.
I tried to convert the value from string to number using a VBscript, but I always get an error. Do you have any piece of advice?
Thanks for your help
Convert String to Number
Moderator: NiceLabel Support Team
Re: Convert String to Number
In similar project used python script: Result.Value = float(Weight.Value.replace(',', '.'))
Weight variable type used floating point
Weight variable type used floating point