Click to See Complete Forum and Search --> : substr


mike@work
April 30th, 2001, 03:16 PM
Please reply to this question. Previous one went to home email address. I'm at work.

Is there a substr equivelent in VB. I use it in perl. I want to be able to extra "pm" in a date variable

Andrew_Fryer
May 2nd, 2001, 02:31 AM
use the Mid function

Cimperiali
May 2nd, 2001, 02:49 AM
Have a look also at instr function. It will help you find what you want inside a string (to give correct parameter to Mid function when you do not know exactly how is written a string)


Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.

Sheryll018
October 10th, 2005, 04:23 AM
Is there a substr equivelent in Visual c++ (mfc)? thanks.

Beekman
October 10th, 2005, 05:17 AM
You can make your own function, 'cause I don't think there's a good function...

Something like this I guess?

char* subStrng(char* const chrOrig, int begin, int size)
{
char *chrNew = new char[size];

for (int i=0; i<size; i++) {
chrNew[i] = chrOrig[i+begin];
}

return chrNew;
}

Edit;
I think CString has a mid-function... maybe you can use that;
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_cstring.3a3a.mid.asp