So on my program it is supposed to find the word positions and place them in a text box example: Hi i am bdmaurice and i am new would be 1 2 3 4 5 2 3 6.
This is my code so far i just needed a bit of help to make it work.
And in the text box it says: new and then in both list boxes it says: 1Code:Imports System.Windows.Forms.VisualStyles.VisualStyleElement.Menu Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click TextBox2.Text = "" ListBox1.Items.Clear() ListBox2.Items.Clear() Dim ArrayX() As String = Split(TextBox1.Text, " ") Dim Number As Integer = 0 Dim List As New Dictionary(Of String, String) Dim item As String For Each item In ArrayX Next If Not List.ContainsKey(item) Then Number = (Number + 1) List.Add(item, Number) End If 'displays the numbers for each word in a list ListBox2.Items.Add((List(Item))) 'displays the dictionary list of items with their assigned numbers For Each item In List(item) ListBox1.Items.Add(item.ToString.Replace("[", "").Replace("]", "")) Next 'adds all the numbers to textbox2 and adds spaces after each For Each item In ListBox2.Items TextBox2.Text = TextBox2.Text & (item) & " " Next 'converts the numbers into their given words in textbox2 from it's number TextBox2.Text = String.Join("|", Array.ConvertAll(TextBox2.Text.ToArray, Function(c) If(List.Keys.Contains(c.ToString), List(c.ToString), c.ToString))) TextBox2.Text = String.Concat(Array.ConvertAll(TextBox2.Text.Split("|"c), Function(s) If(List.Values.Contains(s), List.First(Function(kvp) kvp.Value = s).Key, s))) End Sub Private Function Item() As String Throw New NotImplementedException End Function End Class
Thanks!




Reply With Quote
