title: How to determine if a value of a key exist in my settings vb.net
body: <p>i have start to develop a new application to generate md5 hashes from strings and the it save automatic to my.settings.md5_hashes 
  and now i need to check if a certain value all ready exist in my settings md5_hashes. i have find some examples but it give me all ways a error on it
  the error 
  Error   1   Value of type 'System.Collections.Specialized.StringCollection' cannot be converted to 'String'.
  how can i check if a value its all ready exist on my settings?</p>
  
  <p>This is my code</p>
  
  <pre><code>Public Class Form3
  
  
  
  Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  
      If My.Settings.md5_hashes = (TextBox1.Text) Then
  
      End If
  
      If Not My.Settings.md5_hashes = (TextBox1.Text) Then
          Me.Show()
      End If
  End Sub
  End Class
  </code></pre>
  
  <p>This is the code to generate the hashes and save it to my.settings.md5_hashes</p>
  
  <pre><code>Imports System.Text
  Imports System.Security.Cryptography
  Imports System
  Imports System.Collections
  Imports System.Collections.Specialized
  
  Public Class Form1
  
  
  Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
      My.Settings.md5_hashes.Clear()
  End Sub
  
  Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
      Dim md5 As MD5 = System.Security.Cryptography.MD5.Create()
      Dim inputBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(TextBox1.Text)
      Dim hash As Byte() = md5.ComputeHash(inputBytes)
      Dim sb As New StringBuilder()
      For i As Integer = 0 To hash.Length - 1
          sb.Append(hash(i).ToString("x2"))
      Next
      TextBox2.Text = sb.ToString
      ListBox1.Items.Add(TextBox1.Text + "&lt;---&gt;" + TextBox2.Text)
  
      My.Settings.md5_hashes.Add(TextBox1.Text + "&lt;---&gt;" + TextBox2.Text)
  
      My.Settings.Save()
  
  
  
  
  
  End Sub
  
  Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  
      For Each item In My.Settings.md5_hashes
          ListBox1.Items.Add(item)
      Next
      Timer1.Start()
  End Sub
  
  Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  
  End Sub
  
  Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
      TextBox1.Text = ""
      TextBox2.Text = ""
      ListBox1.Items.Clear()
  
  End Sub
  
  Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
      Form2.Show()
  End Sub
  
  Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
      Dim W As IO.StreamWriter
      Dim i As Integer
      W = New IO.StreamWriter("C:\MD5.txt", True)
  
      For i = 0 To ListBox1.Items.Count - 1
          W.WriteLine(ListBox1.Items.Item(i))
      Next
      W.Close()
      MsgBox("You File Is Save You Can Locate It At C:\MD5.txt")
  End Sub
  
  Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
      Form3.Show()
  
  End Sub
  End Class
  </code></pre>
  
  <p>well i have just change some part of the code 
  this is my new code</p>
  
  <pre><code>Imports System.Text
  Imports System.Security.Cryptography
  Imports System
  Imports System.Collections
  Imports System.Collections.Specialized
  
  Public Class Form1
  
  
  Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
      'My.Settings.md5_hashes.Clear()
  End Sub
  
  Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
      Dim md5 As MD5 = System.Security.Cryptography.MD5.Create()
      Dim inputBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(TextBox1.Text)
      Dim hash As Byte() = md5.ComputeHash(inputBytes)
      Dim sb As New StringBuilder()
      For i As Integer = 0 To hash.Length - 1
          sb.Append(hash(i).ToString("x2"))
      Next
      TextBox2.Text = sb.ToString
      ListBox1.Items.Add(TextBox1.Text)
      ListBox1.Items.Add(TextBox2.Text)
  
      My.Settings.md5_hashes.Add(TextBox1.Text)
      My.Settings.md5_hashes.Add(TextBox2.Text)
      My.Settings.md5_hashes.Add("&lt;---&gt;")
  
      My.Settings.Save()
  
  
  
  
  
  End Sub
  
  Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  
      For Each item In My.Settings.md5_hashes
          ListBox1.Items.Add(item)
      Next
      Timer1.Start()
  End Sub
  
  Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  
  End Sub
  
  Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
      TextBox1.Text = ""
      TextBox2.Text = ""
      ListBox1.Items.Clear()
  
  End Sub
  
  Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
      Form2.Show()
  End Sub
  
  Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
      Dim W As IO.StreamWriter
      Dim i As Integer
      W = New IO.StreamWriter("C:\MD5.txt", True)
  
      For i = 0 To ListBox1.Items.Count - 1
          W.WriteLine(ListBox1.Items.Item(i))
      Next
      W.Close()
      MsgBox("You File Is Save You Can Locate It At C:\MD5.txt")
  End Sub
  
  Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
      Form3.Show()
  
  End Sub
  End Class
  </code></pre>
  
  <p>well now its return true but how can i get the value to show on a msgbox the results?
  well i solved my self the way to get results of the name for example if i search with the name to retrieved the hash , but how to do if i search for a hash and get the name how to take the name i stored initial there ? </p>