Results 1 to 4 of 4

Thread: Fellow earthlings, my planet needs your help!

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Posts
    395

    Fellow earthlings, my planet needs your help!

    I have absolutely no idea why this wouldn't work? I thought it was working last night but apparently not?

    What I'm trying to do is prevent an item from being added to the Listbox1 list twice...

    So if the item is within the log, dont add it to listbox1. If it's not in the log or in listbox1 then add it.

    If its not in logcmb but already in listbox1 then don't add it.

    The logcmb is saved and loaded at form load and unload.

    Code: Code:
    1. If LogCmb.Items.Contains(tmp) Then
    2.                     'don't add it
    3.                 Else
    4.                     If ListBox1.Items.Contains(tmp) Then
    5.                         'This is already in the list
    6.                     Else
    7.                         If InStr(tmp, "http") Then
    8.                             'if the string contains http then don't add it
    9.                         Else
    10.                             ListBox1.Items.Add(LCase(tmp))
    11.                             statusbarlbl.Text = ListBox1.Items.Count & " available"
    12.                         End If
    13.                     End If
    14.                 End If


  2. #2
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Fellow earthlings, my planet needs your help!

    Try something like this:
    Code:
    If tmp.IndexOf("http") = 0 AndAlso LogCmb.Items.Contains(tmp.ToLower) = False Then
      ListBox1.Items.Add(tmp.ToLower)
      statusbarlbl.Text = ListBox1.Items.Count & " available"
    End If

    And don't make a new thread asking the same question
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  3. #3
    Member
    Join Date
    Feb 2008
    Posts
    44

    Re: Fellow earthlings, my planet needs your help!

    I think maybe the problem is that you are changing the item to all lower case when you add it. So when the item is checked against existing items if it has upper case letters then it won't match.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Posts
    395

    Re: Fellow earthlings, my planet needs your help!

    Quote Originally Posted by JuggaloBrotha
    Try something like this:
    Code:
    If tmp.IndexOf("http") = 0 AndAlso LogCmb.Items.Contains(tmp.ToLower) = False Then
      ListBox1.Items.Add(tmp.ToLower)
      statusbarlbl.Text = ListBox1.Items.Count & " available"
    End If

    And don't make a new thread asking the same question
    Thanks boss.
    8 gigs/ram (hey why not)
    300 gig HD x2
    Windows XP 64

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