Professional Documents
Culture Documents
Click on Windows Form Application, and name the project "Your name's
Dictionary" and then click Ok.
Add another text box to the form and change it's property to Multiline:
Resize the textbox you just added and add a label above it. Change the label text to
Definition:
Add a listbox to the form and place it like the picture below:
ListBox1.Items.Add("abandon")
ListBox1.Items.Add("abandoned")
ListBox1.Items.Add("abandonment")
ListBox1.Items.Add("abandons")
ListBox1.Items.Add("abase")
ListBox1.Items.Add("abased")
ListBox1.Items.Add("abasement")
ListBox1.Items.Add("abash")
ListBox1.Items.Add("abashed")
ListBox1.Items.Add("abate")
ListBox1.Items.Add("abated")
ListBox1.Items.Add("abatement")
End Sub
Notice how the English words are inserted into the code. You can add all English
words to the dictionary.
Adding the list of English words to the dictionary will take a lot of time, specially
that you have to insert every single word in the codes. It would be easier if we use
a database to store the words and retrieve them. But think about it this way: if you
are programming a dictionary, you know exactly what words to add and what
definitions, so the user will not update words and add definitions and that's why we
do not need a database.
We want to make sure the words are listed in alphabetical order. To do that, add
the following code between the last English word inside the code and End sub:
ListBox1.Items.Add("abatement")
ListBox1.Sorted = True
End Sub
We will add a code that when you start typing in the search box, the listbox will
highlight or select a matching word.
Double click on the textbox and add the following highlighted code:
When you type a word in the search box, the word will highlight in the listbox
Let's program the Search button, so when the user types a word an clicks the
button, they get the definition in the big text box.
Let's say the user wants the definition of the word ABACUS, so they types the
word abacus in the search box and they hit the search button. They suppose to get
the following definition:
A manual computing device consisting of a frame holding parallel rods strung with
movable counters.
Double click on the search button and add the following highlighted code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton1.C
lick
If TextBox1.Text = "abacus" Then
TextBox2.Text = "A manual computing device consisting of a frame holding parallel rods strung with movable
counters."
ElseIf TextBox1.Text = "abash" Then
TextBox2.Text = "To make ashamed or uneasy; disconcert."
Else
'A message box will show up if the entered word is not found
MsgBox("No mathcing results where found")
End If
End Sub
You might also add a feature to the dictionary that when the user double clicks on
a word in the listbox, the definition will show for the selected word. To do that: on
the designer page, single click on listbox1, change the properties window to events
like follows:
Look for DoubleClick event, and double click on the empty bar next to it: