APP DIZIONARIO CON VISUAL BASIC
Oggi realizzeremo un dizionario standalone (si avvia senza installazione) con visual basic 6 SP6
Componenti:
- Form
- Label1 e Label2
- TextBox
- CommandButton
- ListBox
Ecco un’anteprima dell’applicazione:
Le scritte in rosso sono la descrizione della disposizione dei componenti da inserire nel form.

Prima di procedere
- Rinominare il CommandButton in cmdCheck
- TextBox in txtWord
- ListBox in lstSuggestions
Codice
Doppio click nella Form e inseriamo il quanto segue
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
Option Explicit Dim MSWord As Word.Application Private Sub Form_Load() Set MSWord = New Word.Application End Sub Private Sub cmdCheck_Click() Dim text As String Dim suggestion As Word.SpellingSuggestion Dim colSuggestions As Word.SpellingSuggestions text = Trim$(txtWord.text) If text = "" Then MsgBox "Non hai ancora inserito niente", vbExclamation txtWord.SetFocus Exit Sub End If If MSWord.Documents.Count = 0 Then MSWord.Documents.Add End If lstSuggestions.Clear If MSWord.CheckSpelling(text) Then lstSuggestions.AddItem "La parola è corretta, non c'è nessun suggerimento" Else Set colSuggestions = MSWord.GetSpellingSuggestions(text) If colSuggestions.Count = 0 Then lstSuggestions.AddItem "Nessun suggerimento" Else For Each suggestion In colSuggestions lstSuggestions.AddItem suggestion.Name Next End If End If End Sub Private Sub Form_Unload(Cancel As Integer) MSWord.Quit End Sub |
Proprietà del Form
