LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to scan numbers with both decimal separators from string

Hello everyone,

 

How to scan for a number regardless of whether decimal separator is a comma (,) or a dot (.)?

 

I am aware that you can specify one or the other (%. or %,), but how can I make that both "6,4" and "6.4" would be converted to a number?

 

Now I am using "Scan From String".

 

The only option I see is to replace all the dots by commas. Can it be natively done with "Scan From String"?

 

0 Kudos
Message 1 of 3
(1,186 Views)

@nicknamenickname wrote:

The only option I see is to replace all the dots by commas.


That's what I would do (except replace all commas with periods 😉 )

 

(I am sure you know that you can do it in one step when selecting "replace all=TRUE")

0 Kudos
Message 2 of 3
(1,177 Views)

Hello nickname,

 

Can it be natively done with "Scan From String"?

Nope, not to my knowledge.


@nicknamenickname wrote:

Hello everyone,

 

How to scan for a number regardless of whether decimal separator is a comma (,) or a dot (.)?

 

I am aware that you can specify one or the other (%. or %,), but how can I make that both "6,4" and "6.4" would be converted to a number?

 

Now I am using "Scan From String".

 

The only option I see is to replace all the dots by commas.

 


I think that's one valid option. I sometimes implented a check it my number string contains a dot and then selected the appropiate format-string %.,%f or %,;%f



Regards, Jens

Kudos are welcome...
0 Kudos
Message 3 of 3
(1,156 Views)