|
Use a Regex : "\w+" will match each word, you can then just use the match count. You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
You can use the IndexOf method inside a for loop to count all the spaces contained in the string.
Or, you can write a RegEx that matches a word and count the number of matches (EDIT: beaten by OriginalGriff on this one ).
|
|
|
|
|
Mirko1980 wrote: beaten by OriginalGriff on this one
nah, nah, de nah-nah!
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
OriginalGriff wrote: nah, nah, de nah-nah!
and how many words is that? 5 according to Regex? 4 when splitting by white-space? 0 according to Webster?
|
|
|
|
|
|
kevinwell wrote: It works with the splitfunction. But can anyone help me with this becaus I don't want you use the split function.
Smells like homework to me. You only get these kinds of requirements when an instructor hands out assignments.
In any case, since you seem incapable of figuring this out on your own...
Just iterate through each character of the string, and wehenever you encounter a space (or a tab), increment a counter. At the end of the loop, add 1 to the counter, and that's how many words are in your string..45 ACP - because shooting twice is just silly ----- "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." - J. Jystad, 2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: At the end of the loop, add 1 to the counter, and that's how many words are in your string.
Unless the string is empty, only whitespace, has multiple whitespace characters in a row (e.g., "\r\n"), or contains leading/trailing whitespace.
|
|
|
|
|
I have a C# 3.5 Windows form application that uses the webbrowser control.
This control is used to navigate through a website, where I have a parsing engine that pulls data off the site and stores it in a file. The customer navigates to the site, presses the "record" button and the parsting starts.
The parser is triggered by the DocumentComplete event. This works very well, but I have seen that this event sometimes does not fire. The customer has to navigate through 500 pages and by the time they get to page 500, we found that we are missing maybe 5-6 of the pages.
We have traced the problem to be that the documentcomplete event is not firing all the time. My debug code indicates that the navigating and havigated events have fired correctly, but not the document complete.
At the end of the 500 page run, I have 500 navigating events, 500 navigated events and a variable number of documentcompelte events, ranging from 490-495. We have not traced it to any single page, but are unable to figure out what is causing this. We even added a sound that beeps when the page loads and have found pages that load in the browser and are viewable, but the sound does not play because the event didn't fire. Any thoughts what might be causing this?
|
|
|
|
|
It could very easily be the server that caused the problem. It's not guaranteed that you will get a DocumentCompleted for every nagivation. You're only recourse is to put a timer in there and if the page does not complete within, say 1 minute, retry the navigation.
|
|
|
|
|
Dave,
Thank you for the reply. Your recommendation makes sense. However, I was unaware that I am not guaranteed a DocumentCompleted event for each successful navigation. What would couse the DocumentCompelted not to fire?
The strange thing is, I can see the page in the browser and I can interact with it, so the page has loaded (or so it seems), but again no DocumentCompleted event.
Can you elaborate on when I can expect the event to fire and when not to?
thanks for the reply.
Jon
|
|
|
|
|
Jon Braunsma wrote: What would couse the DocumentCompelted not to fire?
The server not sending a complete document or a missing HTML closing tag.
|
|
|
|
|
You could always fire your own event when you get a response back from the server..45 ACP - because shooting twice is just silly ----- "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." - J. Jystad, 2001
|
|
|
|
|
For debugging purposes, you could try the following:
1. get the target URL from the Navigating event;
2. cancel the Navigation;
3. use your own code to fetch the page text, using HttpWebRequest and HttpWebResponse;
4. when the response is in, stuff the result into WebBrowser.DocumentText
You can now add logging/debugging stuff to step 3 until you discover what is going on; then work from there.
BTW: I am not suggesting you do this as the final solution! A timeout/retry scheme seems fine, the one problem with it is you'll never know what exactly is going wrong.
|
|
|
|
|
I like the idea of digging in to this deeper. I need to figure out what is causing this event not to fire and this seems like a very good way to help isolate it. Thank you.
|
|
|
|
|
Thank you all for the input. By using a combination of solutions recommended, I was able to detect the condition. After the navigated event fires, I set a timer and if the documentcomplete event does not fire in the specified time, I can immediately detect the issue and alert the user. This is an acceptible work around for now. I will dig more in to the issue later.
Thank you all for the advice.
|
|
|
|
|
hi all,
I had developed one application in c#. My problem is there are 3 forms in my application but first forms controls get hide automatically. control is display in property list but not shown on the form.
Why it is happening?
any solution for this.
Its urgent.
|
|
|
|
|
any code can we see? EASY COME EASY GO
|
|
|
|
|
there is not any code problem?
Control is getting hide automatically?
|
|
|
|
|
If the program isn't doing what you intended, the problem is in the code..45 ACP - because shooting twice is just silly ----- "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." - J. Jystad, 2001
|
|
|
|
|
sn0011 wrote: Control is getting hide automatically?
There is no such thing. You have a code problem somewhere.
What are you doing in Form Load? Do you have any other process that is consuming the CPU in that form? Does the app still respond on other forms? What does the code look like?
|
|
|
|
|
I have one datagridview with three columns first is for category dropdown second for product dropdown third for price textbox all are datagridviewcolumns is taken.
My problem is that i want to show only those product whose category is selected from category dropdown and then price for those products which is selected by product dropdown. This is for each row for datagridview.
Now i want to save and update them in database with three fields 1.id 2.categoryid 3.productid 4.price and if there is any row in table then it populate when form load with rows in datagridview with appropiate value and then i want to change it again it give facility to change and add new record and then it save or update the data.
How Please give me any code or link if anybody have.
Thanks.
Diwakar
|
|
|
|
|
URGENTLY,, i wanna build NetMeeting, how to built it, what the function in this software??
|
|
|
|
|
oh, oh, oh!! How exciting, yipeee!
We are so happy you shared and want to include us all in your project!
Let us all research everything for you, compose relevant documentation and then code it, showing you every step of the way how and why stuff works like it does!
Can we, please?var question = (_2b || !(_2b));
|
|
|
|
|
I've got a spare afternoon on Friday, if you want to split the work? You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Good day, please help.
I have this program I'm busy writing and I have no clue how to do this: when a user starts a program, I want to "intercept" and "pause" the program while its loading and prompt the user to "ALLOW" or "KILL" the program. If anybody has used Kaspersky's Internet Security, it is implemented in there - an alert pops up prompting the user to allow the program to finish executing or cancel it.
Please help, charles
|
|
|
|