Results 1 to 5 of 5

Thread: [RESOLVED] How can I fix this code to stop repeating the text lines

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Resolved [RESOLVED] How can I fix this code to stop repeating the text lines

    Hey guys I have this code that loops my reg scanner.

    Private Sub startscanregbutton_Click()


    listreg.Clear
    Text3.Text = Text3.Text & vbNewLine & "Scanning in progress...Please Wait.."

    Dim ixz As Long

    For ixz = 0 To List2.ListCount - 1
    Text1.Text = List2.List(ixz)


    Dim ix As Long



    For ix = 0 To List2.ListCount - 1
    SearchRegMachine List2.List(ix)
    Next


    Text3.Text = Text3.Text & vbNewLine & Text4.Text



    Label3.Caption = str(listreg.ListCount) & " Possible Problematic Registry Keys"
    Text4.Text = "Scanning Complete" & str(listreg.ListCount) & " Possible Problematic Registry Keys Detected."

    Next
    End Sub

    so this is a loop, but in this loop, after each loop it reports on how many problems is found.

    It loops through all the items in list 2, but I would only like it to report after the loop is done for good, as in when the list2 is all done.

    Can anyone tell me how to do this ?

    Thank you!!!!

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: How can I fix this code to stop repeating the text lines

    It looks like you made a mistake copying your code because you have two Dim ixz As Long and two For ixz = 0 To List2.ListCount - 1. In any case try putting

    Text4.Text = "Scanning Complete" & str(listreg.ListCount) & " Possible Problematic Registry Keys Detected."

    after "Next" rather than before it.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: How can I fix this code to stop repeating the text lines

    I have two loops, one loop is inside of another, but I do not think they are dimed the same.

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: How can I fix this code to stop repeating the text lines

    Okay I see that now. If I were to have written that code I would have formatted it this way.

    Code:
    Private Sub startscanregbutton_Click()
    
    Dim ixz As Long
    Dim ix As Long
    
    listreg.Clear
    Text3.Text = Text3.Text & vbNewLine & "Scanning in progress...Please Wait.."
    
    For ixz = 0 To List2.ListCount - 1
        Text1.Text = List2.List(ixz)
        For ix = 0 To List2.ListCount - 1
            SearchRegMachine List2.List(ix)
        Next
        Text3.Text = Text3.Text & vbNewLine & Text4.Text
        Label3.Caption = Str(listreg.ListCount) & " Possible Problematic Registry Keys"
        Text4.Text = "Scanning Complete" & Str(listreg.ListCount) & " Possible Problematic Registry Keys Detected."
    Next
    
    End Sub
    And what that code does is to put the 1st item from List2 into Text1.text and then call SearchRegMachine for every entry in List2. It then puts the second entry from List2 into Text1 (overwriting what was there) and then call SearchRegMachine for every entry in List2 again. That's probably not what you want so how about just one loop like this.
    Code:
    Private Sub startscanregbutton_Click()
    
    Dim ixz As Long
    Dim ix As Long
    
    listreg.Clear
    Text3.Text = Text3.Text & vbNewLine & "Scanning in progress...Please Wait.."
    
    For ixz = 0 To List2.ListCount - 1
        Text1.Text = List2.List(ixz)
        SearchRegMachine List2.List(ixz)
        Text3.Text = Text3.Text & vbNewLine & Text4.Text
        Label3.Caption = Str(listreg.ListCount) & " Possible Problematic Registry Keys"
        Text4.Text = "Scanning Complete" & Str(listreg.ListCount) & " Possible Problematic Registry Keys Detected."
    Next
    
    End Sub
    That doesn't solve the overwriting of Text1 problem but it should be a start.

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: How can I fix this code to stop repeating the text lines

    thank you kindly, that is much better than the formatting I had!

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