Главная страница | назад





Article #17660: Converting a Variant to a char* and how to check if a Variant is a String

 Question and Answer Database
FAQ2660C.txt Converting a Variant to a char* and how to check if a Variant is a String
Category :ActiveX
Platform :All
Product :C++Builder 3.x
Question:
How to convert from a Variant to a (char *) and
also how to check is a Variant String.
Answer:
// To check type use:
void myFunction(Variant V)
{
if (V.Type() == varString)
{
// to convert to char *
String VarStr(V);
char *cPtr = new char[VarStr.Length()];
strcpy(cPtr, AnsiString(V).c_str());
}
}
7/2/98 10:32:32 AM

Last Modified: 01-SEP-99