use the function atoi(). (ascii to int)
for example:
CString string = "40";
int zahl = atoi(string); // converts string to int

...this should help you.