I notice that, unlike Format, ToText(Xojo.Core.Locale.Raw, “#,###;-#,###;”) fails to blank a zero value. I’ll file this in Feedback if others confirm this for me.
Create a TextField1 and use this to test in a button action:
Dim value As Integer = Integer.Parse(TextField1.Text.ToText)
MsgBox value.ToText(Xojo.Core.Locale.Raw, "#,###;-#,###;")
has been a way to hide 0 values with Format. This sounds like it breaks a traditional way formatting is to be understood.
https://documentation.xojo.com/index.php/Format:
“The formatSpec can be made up of up to three formats separated by semicolons. The first format is the format to be used for positive numbers. The second format is the format to be used for negative numbers and the third format is the format to be used for zero.”
Ok. I’m glad I posted this here first, instead of Feedback. Looks like new standard is to never blank a 0 value via a formatSpec, and I’ll just have to manually code that when needed.
[quote=369825:@Ralph Alvy]I get it now. I had the logic order backwards. I thought that meant that if the value was 0 then show “”. But it’s the other way around.
Looking over that online doc, I think it only evaluates the first 2 parts of
“###;-###;”
I don’t think it evaluates the 3rd part at all. That is, unlike Format, there is no Zero format (the third part).[/quote]
Hello Ralph, I’m learning here, what I read is:
Format maybe use the 3 parts
the new framework (ToText) format use the standard that is only 2, for positive numbers then ; then sub pattern for negative number
I’ll have to do some tests to learn more about this.
now it only has 2 parts and MsgBox show 0 if there is nothing or 0 inside the TextField1[/quote]
That’s my the point. With Format, I could add that 3rd part and make sure that 0 values are displayed as “”. There is no way to do that with the newer formatSpec. For now, I’m doing things like this:
Sorry, I’m just trying to learn and understand new things.
From what I read, the format is different from Format (uses 3 parts), and the standard that now uses the new .ToText format only uses 2 and will show 0.
[quote=369838:@Alberto De Poo]Sorry, I’m just trying to learn and understand new things.
From what I read, the format is different from Format (uses 3 parts), and the standard that now uses the new .ToText format only uses 2 and will show 0.[/quote]
Thank you Ralph, I didn’t know that I can use an If statement with MsgBox.
Testing your code and what you want to do, this is the simplest way I can find to do it (if having ‘value’):
Dim value As Integer = Integer.Parse(TextField1.Text.ToText)
MsgBox if(value=0,"",value.ToText(Xojo.Core.Locale.Raw, "#,###"))
From what I read, the negative part will use the symbol - if nothing is provided and will follow the pattern from positive value even if other pattern is provided.
I didn’t understand this the first time I read it. I think I do know, but I don’t see a difference between #,##0 and #,###. If the value is 0, both will show 0, if there is no value, then both will display 0, but that’s the way the standard works.
I just wanted to also let you know that I very much appreciate how much you’re willing to learn, and it’s why I’m always happy to help you when you have questions. Never be sorry for wanting to learn!