3 Replies - 359 Views - Last Post: 06 December 2018 - 06:46 AM Rate Topic: -----

#1 whoisit   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 66
  • Joined: 15-October 08

Lists

Posted 01 December 2018 - 04:32 AM

Hi
I have five lists when the first one has four names the second one starts to this happens for the first four the fifth can many names. I disabled list so that only the first three would be filled then list five would start to fill.
What happens is that when the third list has four names the next name I type doesn't appear then after that they do start to appear in list five. below is the code:
    Private Sub TextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBox1.KeyDown
        If e.KeyCode = Keys.Enter Then
            Static fillLists = 1
            Select Case fillLists
                Case 1
                    LstMat1.Items.Add(TextBox1.Text)
                    TextBox1.Text = String.Empty
                    If LstMat1.Items.Count = 4 Then
                        fillLists = 2
                    End If
                Case 2
                    LstMat2.Items.Add(TextBox1.Text)
                    TextBox1.Text = String.Empty
                    If LstMat2.Items.Count = 4 Then
                        fillLists = 3
                    End If
                Case 3
                    LstMat3.Items.Add(TextBox1.Text)
                    TextBox1.Text = String.Empty
                    If LstMat3.Items.Count = 4 Then
                        fillLists = 4
                    End If
                Case 4
                    If LstMat4.Enabled = False Then
                        fillLists = 5
                    End If
                    LstMat4.Items.Add(TextBox1.Text)
                    TextBox1.Text = String.Empty
                Case 5
                    LstNames.Items.Add(TextBox1.Text)
                    TextBox1.Text = String.Empty
            End Select
        End If
    End Sub


Is This A Good Question/Topic? 0
  • +

Replies To: Lists

#2 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 171
  • View blog
  • Posts: 1,025
  • Joined: 05-December 13

Re: Lists

Posted 01 December 2018 - 06:46 AM

I didn't understand anything you just wrote. What is your question, and please put some effort into explaining your problem.
Was This Post Helpful? 0
  • +
  • -

#3 maceysoftware   User is offline

  • Foo
  • member icon

Reputation: 367
  • View blog
  • Posts: 1,569
  • Joined: 07-September 13

Re: Lists

Posted 06 December 2018 - 01:05 AM

While I am in agreement with Sheepings, your code does explain what you are trying to do.

Where are you expecting this missing name to appear? because at the moment it is going into lstMat4.
Was This Post Helpful? 0
  • +
  • -

#4 whoisit   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 66
  • Joined: 15-October 08

Re: Lists

Posted 06 December 2018 - 06:46 AM

This has now been solved (vb forums) I am now several steps ahead from when this post was started.
Hopefully this reply is understandable?
For those interested.
    Private Sub lstMembers_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstMembers.SelectedIndexChanged
        Dim listBoxes = {LstMat1, LstMat2, LstMat3, LstMat4, lstNames}.Where(Function(lb) lb.Enabled).ToArray()
        Dim listBox = listBoxes(0)

        For i = 1 To listBoxes.GetUpperBound(0)
            If listBox.Items.Count = 4 Then
                listBox = listBoxes(i)
            Else
                Exit For
            End If
        Next
        If lstMembers.SelectedIndex <> -1 Then
            listBox.Items.Add(lstMembers.SelectedItem)
            lstMembers.Items.RemoveAt(lstMembers.SelectedIndex)
        End If

    End Sub


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1