CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2009
    Location
    Kuwait
    Posts
    170

    [RESOLVED] finding distinct element from an array

    Hi,
    i have an array with wild character at the end. I use the value in this array in Select statment. Some times the array has same values. I want only distinct values in the array before the select statment. Can some one throw an idea on how to do this
    Code:
    for i=0 to count
    select * from tbl where item like ' " & itemname(i) & "'
    next
    I need distinct element in itemname array

  2. #2
    Join Date
    Jul 2009
    Location
    Kuwait
    Posts
    170

    Re: finding distinct element from an array

    Found the solution
    Code:
    For i = 0 To cno
                notfoundelement = True
                For j = 0 To cno
                    If itemname(i) = sortarray(j) Then
                        notfoundelement = False
    
                    End If
                Next
                If notfoundelement = True Then
                    sortarray(elementcount) = itemname(i)
                    elementcount = elementcount + 1
    
                End If
            Next

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

Featured