[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!!!!
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.
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.
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.
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!