VB6 Repeat Detection?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xexpertdkx
    New Member
    • Jul 2007
    • 18

    VB6 Repeat Detection?

    well im using vb6
    and i got data as string in the list1.additem
    eg.
    label1.caption = Int(rnd*100)
    list1.additem label1.caption

    now i want a detectection of the rnd from the label before it shows on the GUI it rnd instantly i.e checks the list1.additem and if number exist then rnd label1.caption before showing on the GUI.

    result:
    label1.caption = "45"
    list1.additem display 45
    but the next click it states
    label1.caption = "45"
    list1.additem display 45, 45 then that is not what i want
    plz post the codes here for me to use.
  • pureenhanoi
    New Member
    • Mar 2007
    • 175

    #2
    Originally posted by xexpertdkx
    well im using vb6
    and i got data as string in the list1.additem
    eg.
    label1.caption = Int(rnd*100)
    list1.additem label1.caption

    now i want a detectection of the rnd from the label before it shows on the GUI it rnd instantly i.e checks the list1.additem and if number exist then rnd label1.caption before showing on the GUI.

    result:
    label1.caption = "45"
    list1.additem display 45
    but the next click it states
    label1.caption = "45"
    list1.additem display 45, 45 then that is not what i want
    plz post the codes here for me to use.
    Code:
    Private Sub Command1_Click()
    Dim i As Integer
    Dim isExisting As Boolean
    isExisting = False
    For i = 0 to List1.ListCount-1
           If List1.List(i) = Label1.Caption Then
               isExisting = True          'Value already exist
               Exit For
           End If
    Next
    If Not isExisting Then
        List1.AddItem Label1.Caption
    End If
    End Sub

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      xexpertdkx, Please let us know whether this resolves your problem.

      Comment

      • xexpertdkx
        New Member
        • Jul 2007
        • 18

        #4
        Originally posted by Killer42
        xexpertdkx, Please let us know whether this resolves your problem.
        i dont think it did anything
        i wanted the value in the label1.caption to check whether the value existed in list1 box.

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by xexpertdkx
          i dont think it did anything
          i wanted the value in the label1.caption to check whether the value existed in list1 box.
          I thought that was what the supplied code did. I only glanced at it, but it looked as though it was copying the label caption to the list, only if it wasn't already there.

          Comment

          Working...