Go for it. If the string isn't a number you get exactly the same behaviour as not allowing it. If it is, the expected operation happens
Although, I think VarAdd & VarSub convert the string to a number with LOCALE_USER_DEFAULT. So you'll get differing results for a sum like cVar + "1,08" depending on what kind of separator , is in the current locale, if any.
General FreeBASIC programming questions.
Josep Roca wrote:I never occurred to me to test the implemented operators substracting an string from a number.
Should I remove the checks?
My advice is to be coherent : equivalent operators must give the same results eg : v1 += X and v1 = v1 + X
And the same for all the operations of the same kind eg : '+ , - , *, etc..'
So users will not be surprised depending the way they code.
I'm not familiar with variants and I don't use them so it's up to you.
Who is online
Users browsing this forum: albert and 11 guests