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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert CString to UINT?? CString to COledateTime?

Status
Not open for further replies.

kinzaze

Programmer
Jan 20, 2000
3
FR
i need to convert CString to UINT and CString to COleDateTime i find no function that enable me to do that <br>
any help would be appreciate thanks<br>

 
To convert a CString to a UINT I would use the LPCTSTR operator, then use atoi. Example: <br>
UINT foo (CString in)<br>
{<br>
return atoi(LPCTSTR(in));<br>
}<br>
<br>
Converting a CString to a COleDateTime completely depends on the structure of the CString. There are constructors that take the date and time in many different formats. <br>
<br>
There is probably a pretty slick way to do this that I can't think of right now, but you could pretty easily hack something together.<br>
<br>
For example, if the CString contains &quot;MM/DD/YY HH:MM:SS&quot; you could parse out each element and construct a COleDateTime with the following constructor:<br>
<br>
COleDateTime::COleDateTime(int nYear,int nMonth,int nDay,int nHour,int nMin,int nSec);<br>
<br>
Here are the other constructors that VC+ HELP lists:<br>
<br>
COleDateTime( );<br>
COleDateTime(const COleDateTime&);<br>
COleDateTime(const VARIANT&);<br>
COleDateTime(DATE);<br>
COleDateTime(time_t);<br>
COleDateTime(const SYSTEMTIME&);<br>
COleDateTime(const FILETIME&);<br>
COleDateTime(WORD wDosDate, WORD wDosTime);<br>
<br>
<p>Pat Gleason<br><a href=mailto:gleason@megsinet.net>gleason@megsinet.net</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top