Is there are any way to convert Boolean type into "ON"/"OFF" using string formatter, like:
Dim inpValue as Boolean
Dim outValue = String.Format("0:ON;OFF", inpValue)
' should show OFF as output
without code or IFormatProvider?
What is wrong with:
Dim inpValue as Boolean
Dim outValue = If(inpValue, "ON", "OFF")
Here's a crazy trick from another question but it's completely unreadable. I strongly advise you not to do this! If you are of nervous disposition, stop reading now.
String.Format("{0:ON;ON;OFF}", CDbl(inpValue))
This converts the Boolean to -1 or 0 and then uses a custom numeric format.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With