YIM bunchhat Active Member Licensed User Longtime User Oct 31, 2014 #1 Hello, How can I convert from string to integer or float in B4J?
derez Expert Licensed User Longtime User Oct 31, 2014 #2 Just assign the string to a variable of the wanted type (after checking that the string is a number). B4X: Dim st as string = "543" Dim k as int = st Upvote 0
Just assign the string to a variable of the wanted type (after checking that the string is a number). B4X: Dim st as string = "543" Dim k as int = st
YIM bunchhat Active Member Licensed User Longtime User Oct 31, 2014 #3 Thank I will try and feedback Upvote 0
YIM bunchhat Active Member Licensed User Longtime User Nov 1, 2014 #4 @derez , thank you now it work. But i got too much string character. Ex "9.635287829495450" I want it to trim it to be "9.63" so How can I do? Upvote 0
@derez , thank you now it work. But i got too much string character. Ex "9.635287829495450" I want it to trim it to be "9.63" so How can I do?
derez Expert Licensed User Longtime User Nov 1, 2014 #5 This will give you the rounded value which is 9.64 B4X: Dim st As String = "9.635287829495450" Dim F As Float = st F = NumberFormat(F,1,2) If you want just to cut, use B4X: F = Floor(F*100)/100 instead of NumberFormat. Upvote 0
This will give you the rounded value which is 9.64 B4X: Dim st As String = "9.635287829495450" Dim F As Float = st F = NumberFormat(F,1,2) If you want just to cut, use B4X: F = Floor(F*100)/100 instead of NumberFormat.