Hello ...
I have Made a little example with increasing number and autoconverts to a String but found perhaps a Bug?
'---Script created on 02-24-2024 17:49:57 by lionheart ' ' uses "ui" long flag = 10 flag++ msgbox str$(flag) '11 'thinbasic result 10 ? ' ' number to an increasing string ' '1) string s = "200" s = val(s)+1 '201 msgbox s 'result: "201" 'thinbasic result: 2001 '2) long k k++ s = val(s)+k msgbox s 'result: "202" 'thinbasic result : 2001 '3) string m = " Mona" string st = "3000 " + m st = val(st)+1 msgbox st + m 'result: 3001 Mona 'thinbasic result: 30001 '4) long km = 100 km++ string m =" Mona" string sr ="3000 " + m sr = val(sr) + val(km)+1 msgbox sr + m 'result: 3102 Mona 'thinbasic result: 30001001
Last edited by Lionheart008; 24-02-2024 at 20:26.
you can't always get what you want, but if you try sometimes you might find, you get what you need
First of all, thanks for testing, it is always usefull.
To me all exposes cases are as expected.
++ is not supported by thinBasic, at the moment it is just ignored.
All the other cases ... if thinBasic expects a string, math is for string so + is considered "concatenation" even if before there is a VAL
If you need to sum a number into to a string that represent a number, use a numeric variable as destination like:
Which math to follow (numeric + or + as string concatenation) depends by the destination typelong n string s = "200" n = val(s)+1 msgbox 0, n
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Bookmarks