|
John Simmons / outlaw programmer wrote: NOTE: I didn't want to use the atoi function to determine the validity of the converted string because if it's not a number, it returns 0, which IS a number. It's also a VALID number, so you can't just assume that the return value is what you expect it to be. That's why I included code to check each character one at a time before trying to convert it to a numeric value.
So why not just use strtol() ?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: So why not just use strtol()?
Because like atoi , it returns ZERO if the string cannot be converted.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
True, but unlike atoi() , it has an argument that tells if the entire string was looked at or not.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
There's a bunch of different ways to get to the same point. He used atoi , so I did to. The point really isn't worth arguing, IMHO, but y'all go right ahead and talk amongst yourselves.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Your answer was perfect.
|
|
|
|
|
Bravoone_2006 wrote: m_sum.SetWindowText(csText);
the SetWindowText() must be used after all the loop isn't?
int nsum = 0;<br />
for( int nRow = 0; nRow < m_list1.GetItemCount();nRow++)<br />
{<br />
for( int nColumn = 0; nColumn < 2;nColumn++)<br />
{<br />
CString csText = m_list1.GetItemText(nRow ,nColumn );<br />
nsum += atoi( csText);<br />
}<br />
}<br />
TCHAR tcsum[50]<br />
_itoa( nsum, tcsum, 10 );<br />
m_sum.SetWindowText(tcsum);
nave
|
|
|
|
|
How can i use a non staticmember function for callback purpose
thanks
|
|
|
|
|
See Here[^]
Description of article:
The purpose of this article is to present a method whereby both static and non-static class member functions, as well as non-member functions can be used as callback functions. Type-safety is important in this implementation, and some features are left out in order to retain this.
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
You can't because static member functions and standard member functions don't have the same prototype: for the latter, an implicit this parameter is passed.
The way to solve this problem is that in general, most callback functions allow you to pass some data (in general a pointer). Pass the pointer to your class instance (this) along the address of the static function that will be used for callback. In the callback function, you can then cast back the pointer to your class and call a member function from it (it should be public).
|
|
|
|
|
Actually i need a WindowProc as a member function
|
|
|
|
|
Read this...[^]
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
hi
How can i create an activeX control using an existing one
Arun
|
|
|
|
|
Hi,
Hope one of the following article can help you:
Article 1[^]
Article 2[^]
Article 3[^]
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
hi
tnx
But i need to create a new ActiveX with an existing one.
while i am trying to do so, i am not getting the display properly.
while putting it on a web page there was no display.
when i removed the activex from my new activex it worked.
why it happens so?
|
|
|
|
|
I want to open a excel from vc++.
I used automation..
I am able to open the xls file without any problem..but i am not able to open the text file..
the only problem is Its not delimiting properly...
can anyone help me how to delimit(SPACE)..
This is the code i have used...
---------------------------------------------------
_Application app; // app is the Excel _Application object
COleVariant VOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
_Workbook objBook;
Workbooks objBooks;
Worksheets objSheets;
_Worksheet objSheet;
// app is the Excel _Application object
// Start Excel and get Application object...
if(!app.CreateDispatch("Excel.Application"))
{
AfxMessageBox("Couldn't start Excel.");
}
else
{
//Make Excel Visible and display a message
app.SetVisible(TRUE);
objBooks = app.GetWorkbooks();
long xyz=1;
COleVariant bNo;
bNo.boolVal=FALSE;
COleVariant bYes;
bYes.boolVal=TRUE;
//It is working fine.. only problem is i am not able to specify the delimiters...
// If i open an excel file its working fine... but if i open a text file... its giving error...
//how to separate with delimiter.
//objBooks.OpenText(((
objBooks.OpenText("F:\\test.txt",VOptional,VOptional,VOptional,xyz,bNo,bNo,
bNo,bNo,bYes,bNo,bNo,VOptional,VOptional,VOptional,
VOptional,VOptional,VOptional);
Chitra Sankaran
|
|
|
|
|
Hi,
Read through this thread[^] maybe it can help you.
or
Automate Excel[^]
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
I read already those threads...
The problem is i am not able to read a text file...
how to delimit the text file..
|
|
|
|
|
Why are you using OpenText() instead of Open() ? I use the latter with text files, but OpenText() will work also.
In any case, what error are you receiving?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I am not getting any error...
its opening the text file..
but the problem is...
if my text file contain the data as 27 1 1 0.0 30.0 41.11
it is putting the value as
2 7 1 1 0.0 30.0 41.11
2 in first cell...
7 1 1 in second cell
0.0 30.0 41.11 in third cell...
its not putting 27 in first cell 1 in second cell 1 in third cell and so on...
can u help me...
thanks
|
|
|
|
|
artihcv wrote: can u help me...
I thought I already did. Use:
books.Open("c:\\book1.txt",
COleVariant(0L),
vtFalse,
COleVariant(6L),
vtOptional,
vtOptional,
vtTrue,
vtOptional,
vtDelim,
vtOptional,
vtOptional,
vtOptional,
vtFalse,
vtOptional,
vtOptional); If you still need to use OpenText() , try:
books.OpenText("c:\\book1.txt",
COleVariant(1L),
COleVariant(1L),
COleVariant(1L),
-4142,
vtFalse,
vtFalse,
vtFalse,
vtFalse,
vtTrue,
vtFalse,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional,
vtOptional);
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks a lot sir..
I tried using OpenText.. its working...
sorry to disturb u...
still i am finding it difficult to pass delim...
My delimiter is space...
how to pass space as parameter...
Thanks..
Chitra
|
|
|
|
|
artihcv wrote: how to pass space as parameter...
That's what the tenth argument to OpenText() is for.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
sir.,
one more doubt..
i am having both tab as well as space delimiter in text file...
if i use the above code its giving boxes...
how to overcome that..
|
|
|
|
|
artihcv wrote: if i use the above code its giving boxes...
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
sir one more doubt...
i am having both space and tab delimiters in my text file..
if i use the above opentext i am gettting boxes only..
how to overcome this..
Thanks in advance
chitra
|
|
|
|