VSSpell Tutorial > Step 5: Provide Spell Checking for Arbitrary Strings (Bottom Panel) |
This part of the demo allows the user to change the contents of a list box and to spell check each item by clicking a button. In this case, the VSSpell control is not connected to any other controls. All spell checking is done through its Text property.
First of all, add the following two routines to connect the Text3 and List1 controls.
Example Title |
Copy Code
|
---|---|
Private Sub List1_Click() Text3 = List1.List(List1.ListIndex) End Sub Private Sub Text3_Change() List1.List(List1.ListIndex) = Text3 End Sub |
The first routine copies a selected item from List1 into Text3. The second copies the contents of Text3 into List1 when the user makes any changes.
The final step is the routine that does the spell checking. It simply scans the List1 control checking each list item and setting its selected state to True if no spelling errors were found, or False otherwise. Here is the code:
Example Title |
Copy Code
|
---|---|
Private Sub Command2_Click() ' Prepare control. VSSpell3.BadWordDialog = vsspellNoDialog VSSpell3.Suggest = False ' Spell check listbox items, and select entries that look okay. Dim i As Integer For i = 0 To List1.ListCount - 1 VSSpell3.Text = List1.List(i) VSSpell3.CheckText If VSSpell3.BadWordCount > 0 Then List1.Selected(i) = False Else List1.Selected(i) = True End If Next End Sub |
That's it. This demo covers most aspects of the VSSpell control.