"tojo" <To**@hotmail.com> wrote in message
news:MP************************@news.t-online.de...
I have a BSTR with the string "123". I need this as a long (or UINT).
How can I do this? I am a newbie, does it show?
Thanks,
Tom
Loop though the string one character at a time, each time round the loop
multiply the value you have so far by 10, and add the value of the latest
digit.
I.e. in pseudo code
long val = 0;
while (more digits)
{
val *= 10;
val += next digit;
}
In your example val will go like this
val = 0;
val = 0; // times 10
val = 1; // plus digit '1'
val = 10; // times 10
val = 12; // plus digit '2'
val = 120; // times 10
val = 123; // plus digit '3'
Get the picture?
john