Sinisterly
[VB.Net] [Source] Simple Dictionary/Translator etc. - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Visual Basic & .NET Framework (https://sinister.ly/Forum-Visual-Basic-NET-Framework)
+--- Thread: [VB.Net] [Source] Simple Dictionary/Translator etc. (/Thread-VB-Net-Source-Simple-Dictionary-Translator-etc)



[VB.Net] [Source] Simple Dictionary/Translator etc. - Coder-san - 12-02-2010

Using this you can make your own glossary, dictionary, translator, etc.

Code:
Dim wText As String = My.Resources.ListF, FText As String = My.Resources.ListW
Dim a() As String = wText.Split(vbCr), b() As String = FText.Split(vbCr)

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    LoadAll()
End Sub

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
    If ListBox1.SelectedItem <> "" Then TextBox2.Text = a(ListBox1.SelectedIndex).Trim
End Sub

Private Function LoadAll()
    ListBox1.Items.Clear()
    Dim j As Long
    For j = 0 To b.GetUpperBound(0)
        ListBox1.Items.Add(b(j))
    Next
    Return Nothing
End Function

Usage:
Add a ListBox and a TextBox to a form.
Add 2 text files in your resources: ListF, ListW

Now Write in them line by line, corresponding data.

Quote:ListF

A round, firm, fleshy, edible fruit with a green, yellow, or red skin and small seeds
Any round, or spherical, object; sphere; globe


ListW

Apple
Ball

Now run app and click an item in the Listbox, and it will display the corresponding data in the Textbox.

There is no Exception catching so code your own.

Note: This is using vbCr (Enters), so if you want to add multiline data for a single entity then change it to a different uncommon delimiter.

Happy coding. Smile


RE: [VB.Net] [Source] Simple Dictionary/Translator etc. - Th3Proph3t - 12-02-2010

Ha, this is a pretty cool idea. I need to learn some VB.net. Until then, Im gonna copy/paste your code and use it. ^_^