Question

In VisualBasicScript there is a way to print the value of a Boolean variable in English indifferently of the language of the OS?.

If you don't know what I'm talking about then what I mean for example is that I have my OS (Windows 8.1) in Spanish and when I run the next orders:

Bool = True
MsgBox Bool

...It prints "Verdadero" which is the Spanish translation to "True".

And If I try the same using WScript.Echo it prints the numeric representation of the booleans, but well really I'm only interested to do the right conversion for a MsgBox.

I'm not looking for solutions like 'you can check the boolean value like this':

If Bool = True then
    Msgbox("True")
Else
    MsgBox("False")
End If

I'm just asking that if this can be done without writting conditional checks or other involved code, just ...exist any VBS method to convert/print a Boolean value correctlly?.

Was it helpful?

Solution

I'm not sure why you'd want to force English onto someone who has clearly set their locale to Spain, it appears to me they'd want to get the Spanish variant.

However, if you're hell-bent on doing it, one way is with a function called, for example, EnglishBool() which takes a boolean and returns the English string "True" or "False", something like:

Function EnglishBool (boolValue)
    If boolValue Then
        EnglishBool = "True"
    Else
        EnglishBool = "False"
    End If
End Function

Then you call it with:

MsgBox EnglishBool (Bool)

It's still complex in that you have to define the function but the places where you use that function are pretty simple one-liners, no different really to the simple MsgBox Bool (at least in terms of source code).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top