title: NullReferenceException for no reason that I can find
body: <p>Here is my issue (and my code). When I run this, it will loop as expected, checking the values, but eventually, when it finds a value that matches up, it will jump the track. (More info after the code)</p>
  
  <pre><code>    DevCon = DevCon.ToUpper     'Capitalizing everything
      DevIDLeg = DevIDLeg.ToUpper
      DevIDMod = DevIDMod.ToUpper
      DevIDIris = DevIDIris.ToUpper
  
  
      Dim Legacy As String() = DevIDLeg.Split(New Char() {","c})     'Splitting everything by comma's.
      Dim Modern As String() = DevIDMod.Split(New Char() {","c})
      Dim Iris As String() = DevIDIris.Split(New Char() {","c})
      For Count = 0 To 1000 Step 1
          If Count &gt; Legacy.Length = False Then                          'Makes sure we aren't checking more than the all the values that the array can hold
              If DevCon.Contains(Legacy.ElementAt(Count)) = True Then     'Checks to see if the values match
                  RegKey.CreateSubKey("Intel_DEVID")                      'Creates Key, even if it already exists (no outstanding error)
                  RegKey.SetValue("Intel_DEVID", "isLegacy")              'Sets the value of the Key
                  RegKey.Close()                                          'Closes the Key
              End If
          End If
          If Count &gt; Modern.Count = False Then                            'Everything from above (the comments) can be repeated.
              If DevCon.Contains(Modern.ElementAt(Count)) = True Then
                  RegKey.CreateSubKey("Intel_DEVID")
                  RegKey.SetValue("Intel_DEVID", "isModern")
                  RegKey.Close()
              End If
          End If
          If Count &gt; Iris.Length = False Then
              If DevCon.Contains(Iris.ElementAt(Count)) = True Then
                  RegKey.CreateSubKey("Intel_DEVID")
                  RegKey.SetValue("Intel_DEVID", "isIrisHasswell")
                  RegKey.Close()
              End If
          End If
      Next
  </code></pre>
  
  <p>Basically, I have 4 text files, one is generated by an external program, and 3 are of expected possible results. Each loop, the program will check each value to see if it is contained in the string generated by the external program. </p>
  
  <p>When it finds one such value (in my case, it will find it in the Value Modern (the second set of IF's in the loop), on the 5th iteration) It will then start executing the code. <code>RegKey.CreateSubKey("Intel_DEVID")</code>. For some reason, this will cause it to jump to the end of the code, with this error:</p>
  
  <blockquote>
    <p>A first chance exception of type 'System.NullReferenceException' occurred in DevIDParser.exe</p>
  </blockquote>
  
  <p>Above everything (in the Dim's) It is Initialized</p>
  
  <pre><code>Public RegKey As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Removed\for\reasons", True)
  </code></pre>