|
for (ctr=0; ctr <=15; ctr++)
{
dout[ctr]=' ';
}
for (ctr=0; ctr <strlen(strData); ctr++)
{
dout[ctr] = strData[ctr+1];
}
Provided dout and strData are character arrays (but if they are really character arrays, you probably don't need the above code ).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Why are you encouraging that person? I'm afraid this will be come a habit and the OP will come here with VB code on a daily basis. You must answer all of that, as a punishment.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
If he need to translate some VB code to C++ then what would be the right forum?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
What if the VB thing consists 1000+ lines and contains so many GOTO and ON ERROR RESUME NEXT thingies? Okay. My opinion was that the OP could have stated the problem, because she wants to learn Visual C++. Posting some VB code and asking for its Visual C++ equivalent would not teach her anything. Agree?
Also, we don't have a VB to C++ forum. The idea looks dirty to me.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
It also could be a scam too do a school task. Write your task in a pseudo programming language, like that VB thing you're talking about. And then ask us to provide a real program.
codito ergo sum
|
|
|
|
|
BadKarma wrote: It also could be a scam too do a school task. Write your task in a pseudo programming language, like that VB thing you're talking about. And then ask us to provide a real program.
That's funny. Thanks for the humor.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Rajesh R Subramanian wrote: What if the VB thing consists 1000+ lines and contains so many GOTO and ON ERROR RESUME NEXT thingies?
We can give some hints and help her (since you know savitri is a female name, I'm not able to guess it for sure) to go on C++ and more on the OOP way.
Rajesh R Subramanian wrote: Posting some VB code and asking for its Visual C++ equivalent would not teach her anything. Agree?
Maybe someone catches that wrong question and handle it to show the right way.
Rajesh R Subramanian wrote: Also, we don't have a VB to C++ forum. The idea looks dirty to me.
Translating VB to C++ is not dirty at all. You may think the opposite, but there are a few VB skilled developers around (and there are, as well ugly C++ coders...). IMHO attacking VB without strings is only the last childish trend.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I think regardless of the no. of lines of the VB program, if the OP really wants to learn C++, then she must state her problem precisely, just like how everyone else does here. Just my opinion.
CPallini wrote: Maybe someone catches that wrong question and handle it to show the right way.
I'll agree on that.
CPallini wrote: Translating VB to C++ is not dirty at all. You may think the opposite, but there are a few VB skilled developers around (and there are, as well ugly C++ coders...). IMHO attacking VB without strings is only the last childish trend.
You got me wrong here. I was emphasizing on the fact that we must encourage people from learning the new language the proper way, instead of providing them some kind of a "translation service", which may make them get used to this service.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Rajesh R Subramanian wrote: What if the VB thing consists 1000+ lines and contains so many GOTO and ON ERROR RESUME NEXT thingies?
Then you ignore the post and move on. A comment to every post, contrary to popular opinion, is not necessary.
Rajesh R Subramanian wrote: My opinion was that the OP could have stated the problem, because she wants to learn Visual C++.
The problem was stated with code. That's good enough for, and easily understood by, most.
Rajesh R Subramanian wrote: Posting some VB code and asking for its Visual C++ equivalent would not teach her anything. Agree?
No, not at all. But then everyone has a right to their own viewpoint. Some folks are capable of learning a great deal by mapping what they know to a new language.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: Some folks are capable of learning a great deal by mapping what they know and are comfortable with to a new language.
I missed that. Thanks for pointing out.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
CPallini wrote: If he need to translate some VB code to C++ then what would be the right forum?
Coding Horrors[^]
|
|
|
|
|
I spurted out tea man. That's it. I need to read CP or drink tea. I can't mix them both.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
hello everyone,
please tell me solution for this problem please. in my program strData is of type CString. so for this i have to find out the middle value and that value should be stored in dout. please help me.
thanku in advance,
savitri
|
|
|
|
|
Hello Guys,
I am using a static text control and i want when the user click on that static text control then the user will able to go to that page which i link.How should be possible it? Please give me any suggestion.
Will we able to use any message maps or events with static text control?
Also i did not want a hyperlink by using the sethyperlink function.
|
|
|
|
|
Did you can set Notify for static control?
|
|
|
|
|
Search CP for "static hyperlink" controls.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
CMyListCtrl::OnClick(NMHDR* pNMHDR, LRESULT* pResult)
And the parent window need to handel NM_CLICK from the list ctrl too.
Now only the handler in CMyListCtrl will be executed.
How to let both handlers work?
Thanks.
|
|
|
|
|
MFC's global message handler will always use the first handler found. That means you have to forward the message to the parent window yourself.
Don't try it, just do it!
|
|
|
|
|
It doesn't work. When I send WM_NOTIFY in the ctrl's notify message handler, it seems that there is a deadlock.
|
|
|
|
|
Just another way, send my msg instead.
|
|
|
|
|
I've been doing some profiling and have come across a portion of my code that I suspect can be sped up (although it is already quite simple). I have a loop where I do a calculation. In this form:
for (int i = max; i >= 0; i--)
for (int j = 0; j <= limit; j++)
value = calculation(i,j);
The loop is blazingly fast. I can do about 20,000 iterations in a fraction of a second. Then I added an if-else block:
for (int i = max; i >= 0; i--) {
for (int j = 0; j <= limit; j++) {
if (quantity > 0)
value = calculation(i,j);
else
value = 0.0;
}
}
In the above form, the 20,000 iterations can take about a minute. Speed is very important and the simple addition of the if-else brings a huge performance hit - I suspect because the compiler can't optimize the loop. Does anyone see a creative way to remove this if-else block and replace it with something the compiler can optimize? It seems it should be simple, but I can't really think of anything off-hand.
modified on Tuesday, March 4, 2008 3:29 AM
|
|
|
|
|
73Zeppelin wrote: for (int i = max; i >= 0; i--) { for (int j = 0; j <= limit; j++) { if (quantity > 0) value = calculation(); else value = 0.0; }}
if(quantity > 0) {
}
else {
}
Maxwell Chen
|
|
|
|
|
Hi Maxwell, thanks. I should have mentioned the calculation is indexed by the loop. I've been thinking of something like:
#define MAX(x,y) ((x)>(y)) ? (x) : (y)
but then I have to calculate x on each iteration so that isn't an improvement.
|
|
|
|
|
if quantity is not i , j dependent then Maxwell suggestion still applies.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Yes, of course! We shouldn't mislead anyone. Good of you to point that out.
|
|
|
|