Hey guys I have a sub that searches for registry keys I enter in a textbox its caled text1.

The sub that scans is this ..

VB Code:
  1. Private Sub SearchRegMachine()
  2.   Dim i As Integer
  3.     Dim lngKeyHandle As Long
  4.     Dim lngResult As Long
  5.     Dim lngCurIdx As Long
  6.     Dim strValue As String
  7.     Dim lngValueLen As Long
  8.     Dim strClass As String
  9.     Dim lngClassLen As Long
  10.     Dim strResult As String
  11.     Dim lngTime As FILETIME
  12.     Dim strSearch As String
  13.     Dim intSearchLen As Integer
  14.     Dim blnMatch As Boolean
  15.    
  16.    
  17.      'PlaySound App.path & "\StartReg.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
  18.     i = 0
  19.     ' Clear the current results
  20.    
  21.     ' Assign the new string to search for
  22.     strSearch = Text1.Text
  23.     intSearchLen = Len(strSearch)
  24.    
  25.     ' Open the Root Branch to search
  26.     lngResult = RegOpenKeyEx(strBranch, _
  27.             "", _
  28.              0&, _
  29.              KEY_READ, _
  30.              lngKeyHandle)
  31.    
  32.     If lngResult <> ERROR_SUCCESS Then
  33.         MsgBox "Cannot open key.", , "Search Registry Keys"
  34.     Else
  35.     ' If the Root branch can be opened, disable
  36.     ' the buttons and begin the search
  37.         startscanregbutton.Enabled = False
  38.        ' Command2.Enabled = False
  39.         listreg.Enabled = False
  40.         Reg.MousePointer = 11
  41.        
  42.         lngCurIdx = 0
  43.         Do
  44.             lngValueLen = 2000
  45.             strValue = String(lngValueLen, 0)
  46.             lngClassLen = 2000
  47.             strClass = String(lngClassLen, 0)
  48.        
  49.             ' Enumerate all the sub keys
  50.             lngResult = RegEnumKeyEx(lngKeyHandle, _
  51.                  lngCurIdx, _
  52.                  ByVal strValue, _
  53.                  lngValueLen, _
  54.                  0&, _
  55.                  ByVal strClass, _
  56.                  lngClassLen, _
  57.                  lngTime)
  58.            
  59.             ' Increment the index of found keys
  60.             lngCurIdx = lngCurIdx + 1
  61.        
  62.             If lngResult = ERROR_SUCCESS Then
  63.                 ' Trim the current key to its actual length
  64.                 strResult = Left(strValue, lngValueLen)
  65.                
  66.                 ' Eliminate case if the search is insensitive
  67.                 blnMatch = False
  68.                 strValue = strResult
  69.                 If Check1.Value = 0 Then
  70.                     strResult = LCase(strResult)
  71.                     strSearch = LCase(strSearch)
  72.                 End If
  73.  
  74.                 ' Compare strings based upon search type
  75.                 Select Case Combo2.ListIndex
  76.                     Case 0
  77.                         ' Check if any portion of the search string is found.
  78.                         If InStr(strResult, strSearch) Then blnMatch = True
  79.                     Case 1
  80.                         ' Check if an exact match is found.
  81.                         If strResult = strSearch Then blnMatch = True
  82.                     'Case 2
  83.                         ' Check if the search string matches the
  84.                         ' left portion of the key string.
  85.                        ' If Left(strResult, intSearchLen) = strSearch Then blnMatch = True
  86.                    ' Case Else
  87.                         ' Check if the search string matches the
  88.                         ' right portion of the key string.
  89.                         'If Right(strResult, intSearchLen) = strSearch Then blnMatch = True
  90.                 End Select
  91.                
  92.                 ' Populate the list with keys that match
  93.                 ' the search criteria
  94.                 If blnMatch Then
  95.                     i = i + 1
  96.                     listreg.AddItem strValue
  97.                 End If
  98.             End If
  99.        
  100.         ' Keep looking for more keys
  101.         Loop While lngResult = ERROR_SUCCESS
  102.         ' Close the Root Branch
  103.         lngResult = RegCloseKey(lngKeyHandle)
  104.    
  105.         ' Enable the buttons
  106.         Reg.MousePointer = 0
  107.         listreg.Enabled = True
  108.         startscanregbutton.Enabled = True
  109.       '  Command2.Enabled = True
  110.        
  111.         ' Display the total matches
  112.        
  113.    
  114.         Label3.Caption = Str(i) & " Possible Problematic Registry Keys"
  115.        
  116.         Text4.Text = "Scanning Complete" & Str(i) & " Possible Problematic Registry Keys Detected."
  117.     End If
  118.  End Sub

Now basically what it does is searches for registry keys that are inputed in text1 and ptus the result in listreg.

Now is there a way to change it so instead of searching for one at a time in a textbox, it searchs from keys loaded to a listbox one at a time.

Can anyone tell me how to do that?

Thanks!