Finding the Next (Duplicate) Record

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pray2me
    New Member
    • Aug 2008
    • 6

    Finding the Next (Duplicate) Record

    Hi all,
    I am currently involved in a project where I am working with some label arrays. My Problem is that I am using a button that is supposed to find a duplicate label in the array, but I am not sure how to do this....The code that I have right now is actually going to the next label in the array, but not the next duplicate array. Can anybody please help me with this problem??? I will highly appreciate the help. Thank you so much!!!
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Could you please post the code that is currently checking the labels and explain in more detail what it's supposed to be doing.(Please remember to use code tags when posting code snippets).

    -Frinny

    Comment

    • pray2me
      New Member
      • Aug 2008
      • 6

      #3
      I sure can explain it in more detail by giving an example. Lets say there is an array of Labels with texts like "H1", "H2", "H3", "H4", "H1", "H4", so on and so forth. I want a code that actually, finds the labels with same text....It is easy to find if there are different labels. But I am having difficulty as it is a label array. Also, the label array is spread out on different pages, which makes it even more difficult. Any help is appreciated!!!

      Comment

      • vanc
        Recognized Expert New Member
        • Mar 2007
        • 211

        #4
        Originally posted by pray2me
        I sure can explain it in more detail by giving an example. Lets say there is an array of Labels with texts like "H1", "H2", "H3", "H4", "H1", "H4", so on and so forth. I want a code that actually, finds the labels with same text....It is easy to find if there are different labels. But I am having difficulty as it is a label array. Also, the label array is spread out on different pages, which makes it even more difficult. Any help is appreciated!!!
        If you store labels in an array then just go into the array and compare the Text value. I don't see any difficulties here or I miss something?

        Comment

        • r035198x
          MVP
          • Sep 2006
          • 13225

          #5
          You said your code is not doing the right thing. Post it and maybe we can see if there is more to all this.

          Comment

          • pray2me
            New Member
            • Aug 2008
            • 6

            #6
            [code=vbnet]Public Sub SelectItem(ByVa l intSelectedItem As Integer)

            Dim i As Integer = 0
            Dim intFound As Integer = 0


            For i = intItemXrefSize To 1 Step -1
            If intSelectedItem >= intItemXrefArra y(i) Then
            intFound = i
            Exit For
            End If
            Next


            If intFoundPos <> Me.intItemXrefI ndex Then

            intItemXrefInde x = intFound

            FillListPage(in tItemXrefIndex)
            End If



            For i = 1 To Me.intItemMax
            If intLabelXref(i) = intSelectedItem Then
            intFoundPos = i
            Exit For
            End If
            Next

            ItemScreenList( intFound)

            End Sub


            Private Sub ItemScreenList( ByVal intScreenList As Integer)

            gintSelectedIte m = intLabelXref(in tScreenList)

            If gintSelectedIte m = 0 Then

            intScreenList += 1
            If intScreenList <= intItemMax Then
            gintSelectedIte m = intLabelXref(in tScreenList)

            If gintSelectedIte m = 0 Then
            Exit Sub
            End If
            Else
            Exit Sub
            End If
            End If

            intCurrentScree nList = intScreenList
            Me.picCurrentIt em.Top = mlblItemArray(i ntCurrentScreen List).Top + 3


            gintSelectedIte m = intLabelXref(in tScreenList)

            gobjSelectedIte m = gobjXMLItem.Ite m(gintSelectedI tem)



            End Sub


            Private Sub btnNext_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles btnNext.Click

            If gintSelectedIte m < gobjXMLCalendar .ItemCount Then
            gintSelectedIte m = gintSelectedIte m + 1
            End If

            SelectItem(gint SelectedItem)

            End Sub
            [/code]
            This is what I have done so far...but it goes to a next record instead of next duplcate record!!! Can anyone please help me!!! I appreciate it!!!
            Last edited by Frinavale; Nov 15 '08, 03:20 PM. Reason: added [code] tags

            Comment

            • Frinavale
              Recognized Expert Expert
              • Oct 2006
              • 9749

              #7
              Your code isn't checking whether or not the label's text is the same as another.

              You should be doing something like:

              For everyLabel in myArrayOfLabels
              DoesTheLabel.Te xt = theTextYoureLoo kingFor
              If so: add the label to an array of "MatchingLabels "
              Othererwise: don't do anything.

              -Frinny

              Comment

              • pray2me
                New Member
                • Aug 2008
                • 6

                #8
                Hi Frinny,
                Thank you so much for all your time!!! But can you explain a little more by giving a code example. Actually, i tried it but it doesn't work. I want to make sure that I am doing it correctly!!! Thank you

                Comment

                • Frinavale
                  Recognized Expert Expert
                  • Oct 2006
                  • 9749

                  #9
                  Somehow I find it really hard to believe that you cannot translate the pseudo code I mentioned above into VB syntax......

                  Here is an example of the pseudo code that mentioned above.
                  It is not guaranteed to work because I haven't tested it.

                  [code=vbnet]
                  Dim theTextToLookFo r As String = theLabelToCheck .Text
                  Dim theLabelsFound As List(Of Integer) 'Will contain all of the indexes of the labels whose text matches the one you're checking

                  For index As Integer = 0 to myArrayOfLabels .Length
                  Dim lbl As Label = myArrayOfLabels (index)
                  If String.Compare( theTextToLookFo r,lbl.Text,True )=0 Then
                  theLabelsFound. Add(index)
                  End If
                  Next

                  'Now you need to process the Labels that you've found.
                  'I *Think* you're going to have to put this whole section of code within another loop so to loop through each label in the array and check for duplicates...I think...

                  [/code]

                  Try implementing this solution.
                  If it doesn't do exactly what you want it to do (which I'm guessing that it wont) think about how you can modify the code to do what you want it to do...give that a try...and then if you are still having difficulties post the code that you have tried so that we can see what you are doing. We can't help you if you simply say "I tried something but it doesn't work"...you need to provide details on why it doesn't work and, to make it even more clear, you should post the snippet of code that you are having difficulties with.

                  Please do not post all of your code because this makes it hard for us to find exactly what you're talking about. Just post the code that you are having difficulties with.

                  Also please remember to use code tags when posting code snippets.

                  -Frinny

                  Comment

                  • pray2me
                    New Member
                    • Aug 2008
                    • 6

                    #10
                    Thanks Frinny. I appreciate your help and your time. I will use the code tag next time...Thanks once again

                    Comment

                    Working...