Results 1 to 2 of 2

Thread: Checking for existing item in Listview

  1. #1
    Guest
    I'm still no having any luck.


    I'm grabbing text from four texboxes and adding it to a list view with four columns with the click of a button. What is the Syntax for checking if the data I'm about to add to the listview already exists? Here's my current code that adds data to my columns

    Private Sub cmdAddToListView_Click()

    Set sitem = lstCustomers.ListItems.Add(, , txtFields(1).Text)

    sItem.SubItems(1) = txtFields(2).Text
    sItem.SubItems(2) = txtFields(3).Text
    sItem.SubItems(3) = txtFields(4).Text

    End Sub

    Thanks,

    [Edited by vbNuBee on 09-17-2000 at 10:01 PM]

  2. #2
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    258
    Hope it helps
    Code:
    Private Sub Command1_Click()
        'Get the text in the box first
        Dim Uper As Integer
        Dim low As Integer
        Dim Loops As Integer
        Dim rVal As String
        
        For Loops = 0 To List1.ListCount
        
            List1.ListIndex = Loops
            rVal = List1.Text
            If rVal = "One" Then MsgBox "It's already in there "
    
             
            If rVal <> "One" Then List1.AddItem "One"
        
        Next Loops
        
    End Sub
    
    Private Sub Form_Load()
    List1.AddItem "One"
    List1.AddItem "Two"
    End Sub
    Visual Basic 6 SP4 on win98se

    QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!

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