Answered by:
How to add spell check to a rich text box?

Question
-
Hi everyone seeing that my last thread was not answered i made a new specific one....
This is real simple:
How can I add spell check to a rich text box?
Background information:
I built most of my application and I dont want to use wpf rich text boxes because then my code is not compatible. I could use MS Word but it ruins my app up(idk why but anyways i dont want to use becuz then the user has to have word).......
Well I could also accept third party spell checks(which are free) but also please tell me how to use those 3rd party stuff..
Somebody Please Help me outFriday, August 22, 2008 1:20 PM
Answers
-
just download a dictionary, then. Then parse through the RTB and perform a spelling check. I found several spell checkers via Google (some VB6, some web based). It seems most spell checkers simply provide a dictionary and a lookup mechanisim because the variety of things/objects you may want to spell check.
Like I said, parse through your RichTextBox, line by line, word by word, and compare each word to the dictionary. If you add your textual dictionary to a dictionary object, the fast hash lookup should be pretty quick. Or, check words as they are typed: each time a space is entered, spellcheck the previous word.
Looking at the spell checkers, it's really all in the dictionary: you just need a brute-force quick lookup - a dictionary object is very fast.
Stephen J Whiteley- Marked as answer by Martin Xie - MSFT Thursday, August 28, 2008 9:09 AM
Friday, August 22, 2008 7:16 PM
All replies
-
A good starting point would be to Google it: a quick search using Google turned up:
http://www.codeproject.com/KB/recipes/spellchecker_pp.aspx
Google is your friend :)
Stephen J Whiteley- Proposed as answer by Han_BFY Friday, October 29, 2010 6:37 AM
Friday, August 22, 2008 3:13 PM -
Hmm thanks alot I will try out...(Hopefully it wont be one of those which give me a runtime error)....
EDIT: could some give me a little bit help with the above link and like make it easier for me to understand.....I have no idea what the guy is talking about (crting, arrys etc...) I am clueless
TO THE POINT: Could someone help me complete the following:
I have a button named spellcheck and i want it to spell check a rich text box named rtbDoc... any way to accomplish that without doing the hard stuff....
Any Help Would be Greatly Appreciated!
- Edited by Mrtutorial Friday, August 22, 2008 4:42 PM That link is a bit too hard to understand
Friday, August 22, 2008 4:27 PM -
-
I have googled so much(been doing it for 3 days) and well the source codes i found don't work.....BTW the dictionary is not my problem it is the spell check(when the computer searches the richtextbox and verifies it with the dictionary) that gets me.
Also please don't recommend me to use WPF rich text boxes reason my whole application is finished and i just need spell check... I dont want to start from scratch for spel check so...any help is really appreciated! 1 more thing that if you know of any 3rd party spell checkers that are free please tel me...(Like NetSpell Or ETC...)- Edited by Mrtutorial Friday, August 22, 2008 7:02 PM Forgot about the last BTW part
Friday, August 22, 2008 6:57 PM -
just download a dictionary, then. Then parse through the RTB and perform a spelling check. I found several spell checkers via Google (some VB6, some web based). It seems most spell checkers simply provide a dictionary and a lookup mechanisim because the variety of things/objects you may want to spell check.
Like I said, parse through your RichTextBox, line by line, word by word, and compare each word to the dictionary. If you add your textual dictionary to a dictionary object, the fast hash lookup should be pretty quick. Or, check words as they are typed: each time a space is entered, spellcheck the previous word.
Looking at the spell checkers, it's really all in the dictionary: you just need a brute-force quick lookup - a dictionary object is very fast.
Stephen J Whiteley- Marked as answer by Martin Xie - MSFT Thursday, August 28, 2008 9:09 AM
Friday, August 22, 2008 7:16 PM -
SJWhiteley said:
just download a dictionary, then. Then parse through the RTB and perform a spelling check. I found several spell checkers via Google (some VB6, some web based). It seems most spell checkers simply provide a dictionary and a lookup mechanisim because the variety of things/objects you may want to spell check.
Like I said, parse through your RichTextBox, line by line, word by word, and compare each word to the dictionary. If you add your textual dictionary to a dictionary object, the fast hash lookup should be pretty quick. Or, check words as they are typed: each time a space is entered, spellcheck the previous word.
Looking at the spell checkers, it's really all in the dictionary: you just need a brute-force quick lookup - a dictionary object is very fast.
Stephen J Whiteley
Hmm....Well Thanks! But (sorry for being a pain in the neck to you people LOL) my question remains the same: HOW!?!?
I am new to vb so please go easy on me.....
List of things
1.Dictionary Check
2.Rich Text Box Check
3. Method of spell checking uncheck...
You said I should parse every line?
A. What is Parse?
B. How do I Parse?
How can i do the stuff you said above stuff?
Additional Information:
I just want to spell check the text in my rich text box.... the name of the rich text box is rtbDoc BTW.
Friday, August 22, 2008 8:10 PM -
Hmm....Well Thanks! But (sorry for being a pain in the neck to you people LOL) my question remains the same: HOW!?!?
I am new to vb so please go easy on me.....
If you are new to VB, then you should try creating a much easier application. Start small and work you're way up to something like that. With VB, and anything else really, practice will make perfect. I would call myself an 'intermediate' level programmer, I do it in my spare time, and I am only 16. 18 months ago, I couldn't even handle multiple forms, let alone WPF and SQL programming like I can now. (BTW, I need help with a SQL "UpdateCommand", please check my other posts if you can help!)
Grunts are helpless!- Edited by ckerr15 Friday, August 22, 2008 8:46 PM Quote box was too big :-)
Friday, August 22, 2008 8:42 PM -
So uhh...there isnt a easier way to spell check? So to spell check a rich text box i need to practice vb for years and gain knowledge?
Sigh well i guess then my word processor wont have any spell check =/ but I will keep trying! =D
Anyways ty for your help people
If anyone knows hows the easiest way to spell check then please post here ASAP!
Any Help is Highly Appreciated!
Saturday, August 23, 2008 12:15 PM -
You should be able to implement the following:
Read a file, contain a dictionary of words.
Put those words in a Dictionary object.
When the user presses the spell check button, implement a search routine:
Read each word from the text box.
If it exists in the dictionary, then move onto the next word.
If it doesn't exist, show a 'spelling error' dialog box.
Stephen J WhiteleySunday, August 24, 2008 12:28 PM -
I am not saying don't try, but what I am saying is work you're way up to it. I have been doing VB.NET for about 9 months in my spare time around my very busy job. So no, it won't take years, just patience, and maybe a few days of going through Google.
Grunts are helpless!Sunday, August 24, 2008 5:14 PM -
Mrtutorial said:
If anyone knows hows the easiest way to spell check then please post here ASAP!
Simple: GOOGLE!
Have fun!
Grunts are helpless!Sunday, August 24, 2008 5:20 PM -
Hi all! Ran across this thread while trying to include some spell check functionality into my own project and was running into some of the same issues. I haven't implemented it yet, but this looks very promising:
http://msdn.microsoft.com/en-us/library/system.windows.controls.spellcheck(VS.85).aspx
Apparently, if you include the presentation framework into your project and then import the system.windows.controls namespace, then you have access to a spell checker class that you can attach to a rich text box or regular text box. This may be a new thing (or not), but its the first time I've seen it and is exactly what's been needed for years. I hope it works as expected!
cheers!
BFriday, September 11, 2009 3:07 AM -
You have probably solved this already, but I'm posting this because others might find it helpful.
This is for vb6, and I do not know if it works for versions earlier than word 2007, but this runs the full Microsoft Word spell check for a richtextbox while maintaining all of the richtextbox formatting..
First make sure you have the reference
Microsoft Word 12.0 Object Library
Then in a Module,
Global objWord As Object
Finally, on the form with your richtextbox, put a button with the code...
Private Sub Command1_Click()On Error GoTo ERRC
RichTextBox1.SaveFile ("C:\sc.rtf")
DoEventsSet objWord = CreateObject("Word.basic")
objWord.fileopen "C:\sc.rtf"
objWord.StartOfDocument
objWord.EndOfDocument (1)
objWord.ToolsSpelling
objWord.filesaveDoEvents
' closes MS Word
objWord.FileClose (2)
objWord.FileQuit
Set objWord = NothingDoEvents
RichTextBox1.SetFocusRichTextBox1.LoadFile ("C:\sc.rtf")
Exit SubERRC:
Resume NextEnd Sub
Walla, you have the full functionality of microsoft words spell checker, and your entire formatting of your rich text box is maintained.- Proposed as answer by fedge Thursday, October 28, 2010 4:39 PM
Saturday, March 13, 2010 5:21 AM -
Yes... This works in Word 2003, although I made a couple of changes. I used the Microsoft Word 11.0 COM library and added "With Events" to handle the events sent from the Word spellchecker. The only problem I see is that it does not seem to act as intuitively in spotting close words in the Word spell checker. I also have not added "Try" statements to handle errors... have fun!
Public Class frm_ConView
Public objWord As Object
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
RichTextBox1.SaveFile("C:\Users\Public\&&&&TESTY\sc.rtf")With Events(objWord)
objWord = CreateObject("Word.basic")objWord.fileopen("C:\Users\Public\&&&&TESTY\sc.rtf")
objWord.StartOfDocument()
objWord.EndOfDocument(1)
objWord.ToolsSpelling()
objWord.filesave()' closes MS Word
objWord.FileClose(2)
objWord.FileQuit()
objWord = Nothing
End WithRichTextBox1.Focus()
RichTextBox1.LoadFile("C:\Users\Public\&&&&TESTY\sc.rtf")
End SubEnd Class
- Proposed as answer by fedge Thursday, October 28, 2010 4:45 PM
Thursday, October 28, 2010 4:45 PM