Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check if a string is numeric

Status
Not open for further replies.

wallaceoc80

Programmer
Jul 7, 2004
182
GB
Hi,

I'm new to C++ and need to know how to test if a string is numeric.

I'm pulling the string from a grid and all numeric values will be of type double. However, some columns in the grid will have text in them so I need to be able to check this out before I start work with the values.

Any help would be appreciated!

Wallace
 
Just to point out the object I want to check if it is numeric or text is actually of type _variant_t.

 
Hi,

I've tried this but if the value is a string it raises an exception. I can get around this by doing a try/catch but I was hoping there might be something that is a little less expensive as performance is important in the application I'm working on.

Regards,

Wallace
 
I've seen the atof function but can't seem to ge t working. I keep getting a cast error when I write

double temp = atof((char*)vCellValue);

where vCellValue is of type _variant_t.

See why?
 
Ok found a way around that by converting it to _bstr_t first and then converting that to an RWCString.

Any ideas how I can convert a double to an RWCString?

thanks for all the help.

Wallace
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top