Page 1 of 1

StringToFloat$(), StringToInt$() Ploblem Help me!!

Posted: Thu Jun 06, 2019 7:31 am
by seokgi
Hi!

I have a problem.
Something is going on in the process of converting letters to numbers, and I do not get the answers I want. I do not get a good answer when I use the StringToFloat & () function or the StringToInt $ () function. However, if you put "123.4" in the position of String, the value is good. I do not know if there is something wrong with variable assignment or kind. Can anyone tell me what's wrong with the program?
The protocol is repeated as follows.

CD,73,US,NT,+0006.98kg

I put the program together.
Thank you.

Re: StringToFloat$(), StringToInt$() Ploblem Help me!!

Posted: Fri Jun 07, 2019 10:48 am
by Steve
In your code, you are using constants to determine the position of the numbers within your data and I don't think these are set to the correct values.

For example, you have the following:

Code: Select all

Weight_Str1 = Mid$ (Buffer1,Data_Start_Point,Data_Start_Length)
Weight_Str2 = Mid$ (Buffer1,Data_End_Point,Data_End_Length)

Weight_uINT1 = StringToInt$ (Weight_Str1)
Weight_uINT2 = StringToInt$ (Weight_Str2)
Which, if the constant values and sample data are substituted, becomes:

Code: Select all

Weight_Str1 = Mid$ ("CD,73,US,NT,+0006.98kg",16,2)
Weight_Str2 = Mid$ ("CD,73,US,NT,+0006.98kg",19,1)

Weight_uINT1 = StringToInt$ (Weight_Str1)
Weight_uINT2 = StringToInt$ (Weight_Str2)
This would mean Weight_Str1 = "6." and Weight_Str2 becomes "k".