0

I have a two dimensional Array which is filled row by row. I got like ~200 entries. This is variable but also duplicates are filled.

How can i remove those duplicates? Or even check if the entries already exist in the Array and skip that duplicate entry?

for each oSingleNode in oNodeList
    if oSingleNode.xml <> "" Then
          Set oNode = oSingleNode.selectSingleNode("j.8:entity-reference")
          if not oNode is nothing then
              s =  oNode.getAttribute("rdf:resource")
              a = Split(s, "/")
              attribute = a(ubound (a)-1)
              Set oNodeTwo = oSingleNode.selectSingleNode("j.8:entity-label")
              if not oNodeTwo is nothing then
              label = oNodeTwo.text
              array(rowIndex,index) = attribute
              array(rowIndex,constClm)= label
              debug2File array(rowIndex,index) & " " & array (rowIndex, constClm)                         
          End if            
     End if  
End If
Andy
  • 1
  • 1
  • The tool for uniqueness in VBScript is the Dictionary (cf. http://stackoverflow.com/a/6592801/603855). For a specific solution to your problem you should define/exemplify unique/duplicate and decide whether you want to clean a 'dirty' array or to build a clean one. – Ekkehard.Horner Jul 18 '14 at 10:19
  • What is considered a duplicate in your scenario? Individual fields, or entire rows? – Ansgar Wiechers Jul 18 '14 at 11:21
  • i have solution, but not in vb script. – Suji Jul 18 '14 at 12:30

1 Answers1

0

The question was really interesting that's why a make a try on it.sorry for violating the tag since they ware requested for support in vb script, hope that this will make you think of my concept and make try the same in vb script, my result is as follows.

 Dim a(10, 10), i, j As Integer
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 j += 1
 If j > 10 Then
 i += 1
 j = 0
 End If
 check_val(CInt(TextBox1.Text), i, j)
 End Sub

the function will check for duplicates and insert if not exist

        Public Sub check_val(ByVal x As Integer, ByVal i As Integer, ByVal j As Integer)
        Dim t As Integer = 0
        For k As Integer = 0 To 10
        For l As Integer = 0 To 10
        If x = a(k, l) Then
        t = 1
        End If
        Next
        Next
        If t = 0 Then
        a(i, j) = x
        Else
        MsgBox("Repeting value")
        j = j - 1
        End If
        End Sub
Suji
  • 1,326
  • 1
  • 12
  • 27