Click to See Complete Forum and Search --> : how to change from "CString" to "long"??
hazel
Sep 25th, 2002, 02:47 AM
hello..
may i know how to change type from CString to long??
eg., CString------> "123"
to
long --------> 123
is it possible?
pls... help.. sos..
HairyDave
Sep 25th, 2002, 03:24 AM
Use the atol function:
CString str = "123";
long val;
val = atoi(str);
// val = 123
Hope it helps
HD
hazel
Sep 25th, 2002, 03:45 AM
thanks..
:)
transcendental
Sep 25th, 2002, 04:38 AM
Originally posted by HairyDave
Use the atol function:
CString str = "123";
long val;
val = atoi(str);
// val = 123
Hope it helps
HD
I don't think atoi() takes a CString object as its parameter.
Hazel can try
int val=atoi((LPCTSTR)str);
Hope it helps.;)
CornedBee
Sep 25th, 2002, 07:58 AM
CString is automatically converted to LPCTSTR so it works without the explicit cast.
hazel
Sep 25th, 2002, 09:09 PM
hey thank you all guyz!
but "atol" doesn't work or there's something wrong wih my program, i cant get the value...
ok..anyway..thanks..
i'll try again..
hazel
Sep 26th, 2002, 02:44 AM
hi..
i put some update statements and now my program can work..
thanks for the help..
:)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.