HI

Friends i need to convert TCHAR to Boolean value
This is what i want

_TCHAR gstrEnableproxy="false"
o/p:
boolean x=false


and the code i have written is

void convertStringBoolean(String* TCHAR)
{
    bool boolVal = false;
    try
    {
        boolVal = system::Convert::ToBoolean(TCHAR);
    }
    catch(System::FormatException*)
    {
        System::Console::WriteLine("The string TCHAR* System::Boolean::TrueString or System::Boolean::flasestring");
    }
}

Its giving me error and i have try some more way but no use i want to convert TCHAR to boolean

I am writing code in VC++ 2005 version

please help.

Thanks in advance

Recommended Answers

All 3 Replies

>>false"
What the hell is that???

>>void convertStringBoolean(String* TCHAR)
Don't use TCHAR as a variable name because it's a macro defined in standard header file tchar.h which expands to either char and wchar_t depending on whether UNICODE is defined or not.

What is the actual value of that string? Is it either "true" or "false", or is it something else.

Why don't you just say

bool convertStringBoolean(String* str)
{
   return (str == "true") ? true : false;
}

ok

Very first thing dont be so rude...

i want to mention is i have not use TCHAR as variable
I have use it as a type

and i want to convert

>>Very first thing dont be so rude...
I'm not rude. If you want to see rude go to here and see posts by DaWei.

>>i want to mention is i have not use TCHAR as variable
Yes you did. In this line void convertStringBoolean(String* TCHAR) the use of TCHAR is a variable name, String is a type.

And while I'm at it I will suggest you upgrade to VC++ 2010 if you can because CLI langusage has changed since your version of the compiler. For example String* is now String^

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.