Results 1 to 2 of 2

Thread: Need help fixing project

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2016
    Posts
    3

    Question Need help fixing project

    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.

    Code:
    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
    And in the text box it says: new and then in both list boxes it says: 1

    Thanks!
    Last edited by dday9; Oct 18th, 2016 at 08:10 AM. Reason: Added Code Tags

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width