|
i am getting error in following code please help
see the function below
i get date as "Sep-05-2005" which i initially read in smonth
after that take from it smonth as Sep and using switch nmonth as 9
now after taking month and removing it from string -05-2005 is left then
comes day
nday=05
now 05-2005 is left
but when 05 is removed instead of -2005 only -20 is left
this error occurs when first time this function is called on exit
for 2, 3 or ___ no error occurs we get complete -2005
i find this in debug mode
BOOL CXmlData::FnCheckForValidDates(CString szEndDate)
{
//Get Current date
CTime TodayDate=CTime::GetCurrentTime();
int nYear,nMonth,nDay;
CString sMonth;
//date format MM-DD-YYYY
//Extract Month
sMonth=(szEndDate.Left(szEndDate.Find('-')));
//remove the month from String
szEndDate.Replace(szEndDate.Left(szEndDate.Find('-')),""); //-05-2005
//Replace Extra '-'
szEndDate.TrimLeft('-');
//code to get int month from string smonth
if(sMonth == "Jan" )
{
nMonth=1;
}
else if(sMonth == "Feb" )
{
nMonth=2;
}
else if(sMonth == "Mar" )
{
nMonth=3;
}
else if(sMonth == "Apr" )
{
nMonth=4;
}
else if(sMonth == "May" )
{
nMonth=5;
}
else if(sMonth == "Jun" )
{
nMonth=6;
}
else if(sMonth == "Jul" )
{
nMonth=7;
}
else if(sMonth == "Aug" )
{
nMonth=8;
}
else if(sMonth == "Sep" )
{
nMonth=9;
}
else if(sMonth == "Oct" )
{
nMonth=10;
}
else if(sMonth == "Nov" )
{
nMonth=11;
}
else if(sMonth== "Dec")
{
nMonth=12;
}
//Extract Day
nDay=_ttoi(szEndDate.Left(szEndDate.Find('-')));
//remove the day from String//05-2005
szEndDate.Replace(szEndDate.Left(szEndDate.Find('-')),""); but here -20 is left
//Replace Extra '-'
szEndDate.TrimLeft('-');
//Extract year
nYear=_ttoi(szEndDate);
//Expiry date
CTime ExpiryDate(nYear,nMonth,nDay,0,0,0);
//comparison Routine
//first Check year
//comparing todays date with expirey date
if(TodayDate>ExpiryDate)
return FALSE;
#ifdef MYDEBUG
AfxOutputDebugString("Returning True");
#endif
return TRUE;
}
Ankit Aneja
|
|
|
|
|
|
thanks done
but i do not understand why was it giving error that way
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
Ankit Aneja wrote:
i do not understand why was it giving error that way
Because there are two 05 in the string
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
thanks ,very clever
but this was not my code
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
Ankit Aneja wrote:
this was not my code
then whose code is this
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
it is not good to tell person name publiculy because that
person is having good reputation on code project
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
In programming world ppl do not go by their reputation of a good person in codeproject, If s/he writes bad code it means s/he writes bad code plus the ppl in codeproject dont take programming mistakes too personally.
Your comments probably help the dev to understand his mistake.
-prakash
|
|
|
|
|
Hello everybody,
Does anybody know how I can use the method ExecWB of the WebBrowser control for opening a file on the local machine:
ExecWB(OLECMDID_OPEN, OLECMDEXECOPT_DODEFAULT, ?, ?);
I don't know the use of parameters 3 and 4.
I Also don't want to use Navigate method because of the download prompting.
thanks in advance
Roozbeh.
-- modified at 4:14 Saturday 3rd September, 2005
|
|
|
|
|
I wanna to know about this syntax
istream& getline(char *buffer, int length, char terminal_char);
& operator before getline ,what it represent?
Or sometime instead of & there is * also.
What it represent?
Rupal
|
|
|
|
|
hum, i think you need some basic notions about C++.
in such declaration syntax, operator & represent the declaration of a reference, and operator * represent the declaration of a pointer...
in you example, getline get as paramater a pointer to char (buffer), an int (length) and a char (terminal_char). it returns then a reference to an istream instance.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
|
return back the reference of an object
|
|
|
|
|
Rupali Sarda wrote:
What it represent?
Please don't mind, you need read this book, it's contain all the basic concept of c++ Plus it free online http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
hello
I have a dialog based application where i am popping a modeless dialog from the OnInitDialog() of this dialog.I alos have a menu in the parent dialog.What i want is that if user clicks on red cross button and calls OnClose()(WM_CLOSE)then only he should be able to create another modeless dialog through menu.How should i override the OnClose and menu handler.I tried to set a variable of my parent dialog in OnClose of modeless dialog and then check it in OnMenu(0 handler but this is not working.Can somebody expalin to me what happens when we click on red cross button of modeless dialog.Do i need to call destroyWindow()?
please help
thanks in advance
|
|
|
|
|
sayup wrote:
How should i override the OnClose and menu handler.I tried to set a variable of my parent dialog in OnClose of modeless dialog and then check it in OnMenu(0 handler but this is not working.
You have to notify the Parent by sending Some Sort of Custom Window Messages! look for WM_APP and WM_USER messages in your locla copy of MSDN
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
When I compiled my project,I got the error messages below:
<br />
fatal error C1001: INTERNAL COMPILER ERROR<br />
(compiler file 'msc1.cpp', line 1786) <br />
Please choose the Technical Support command on the Visual C++ <br />
Help menu, or open the Technical Support help file for more information<br />
I have checked this error number in MSDN,but I can't solve this problem.
So can anybody here do me a favor?
Appreciate.
Oh,by the way,my environment is VC6.0.
Never understand
radical version!
|
|
|
|
|
The compiler cannot generate correct code for a construct, probably due the combination of an expression and an optimization option. Try removing one or more optimization options and recompiling the function containing the line indicated in the error message.
|
|
|
|
|
ILoveCS wrote:
ILoveCS
as your name suggest you love C-Sharp, what are you doing with VC
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
In your eyes,"CS"just means C sharp.
In fact,it can have many kinds of explanation.
For example,Computer Science.
I love C Sharp.
And I love c++ too.
C sharp and C++ don't mind sharing my loves with each other.
hei,guy,maybe you can give me some advice on my problem?
Never understand
radical version!
|
|
|
|
|
ILoveCS wrote:
In fact,it can have many kinds of explanation.
Goos Shot ....
ILoveCS wrote:
maybe you can give me some advice on my problem?
I believe, Mr. Dunn have already given answer to your problem .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
|
Does it make any difference?
I want to know more.
Thank you.
Never understand
radical version!
|
|
|
|
|