[AccessD] Difference in strings

John Ruff papparuff at attbi.com
Fri Apr 18 19:01:10 CDT 2003


I'm not quite sure what you are trying to do.  If you are trying to delete
items in the listbox that you have not selected, then there is no code that
I am aware of, however, here is code that should work.

' This procedure removes the items from the listbox.
    Dim varCount As Variant
    Dim arrItem() As Variant
    Dim i As Integer
    
    i = 0
    ' Redim the variable arrItem to the number
    ' of items in the lstTest listbox
    ReDim arrItem(lstTest.ItemsSelected.Count - 1)
    ' Loop through the lstTest listbox
    For varCount = 0 To lstTest.ListCount - 1
        ' If the item in the listbox has not been
        ' selected, move its value to the arrItem array
        If lstTest.Selected(varCount) = False Then
            arrItem(i) = lstTest.Column(0, varCount)
            ' Increment the arrItem counter by 1
            i = i + 1
            
        End If
    Next varCount
    
    ' Loop through the arrItem array
    For i = LBound(arrItem) To UBound(arrItem)
        ' Loop through the lstTest listbox
        For varCount = 0 To lstTest.ListCount - 1
            ' If the value in the listbos equals the value
            ' in the array, remove the value from the listbox
            ' and the exit the listbox loop
            If lstTest.Column(0, varCount) = arrItem(i) Then
                ' If you want to delete the item from the
                ' listbox's underlying recordset (RowSource)
                ' you can use a Delete query.
                ' Sample: DoCmd.RunSQL "DELETE * FROM YourTableName " & _
                            "WHERE ClientID=" & CLng(arrItem(i))
                
                ' Remove the item from the listbox
                lstTest.RemoveItem (varCount)
                ' Requery the listbox for the current items
                lstTest.Requery
                Exit For
            End If
        Next varCount
    Next I


Now if you are trying to delete those items in the list box that were
selected, you can change the code for that.


John V. Ruff - The Eternal Optimist :-)
Always Looking For Contract Opportunities

www.noclassroom.com
Live software training
Right over the Internet

Home: 253.588.2139
Cell: 253.307/2947
9306 Farwest Dr SW
Lakewood, WA 98498

"Commit to the Lord whatever you do,
	and your plans will succeed." Proverbs 16:3



-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Stoker, Kenneth E
Sent: Friday, April 18, 2003 3:49 PM
To: dba-AccessD (E-mail)
Subject: [AccessD] Difference in strings


Everyone,

Is there a built-in function in VBA that will compare two strings and return
the difference of the two?  I want to remove values from a listbox so I
thought I could set one variable to the listbox rowsource and another
variable to the listbox itemsselected and return the difference of the two.
If there is a built-in function, I would rather use that than create my own,
but will if I have to.

Thanks.

Ken Stoker
Technology Commercialization
Information Systems Administrator
PH: (509) 375-3758
FAX: (509) 375-6731
E-mail:  Kenneth.Stoker at pnl.gov 


_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list