title: VB.NET: Check if input in textbox is in string array
body: <pre><code>Private Sub txtQty_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtQty.GotFocus
     Dim strItem As String
     strItem = txtItem.Text
     Dim strArray As String
     strArray = itemArr(1)
  
     If String.Compare(strItem, strArray) = True Then
         MessageBox.Show("item in array!")
     End If
  End Sub
  
  Private Sub txtQty_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtQty.TextChanged
  
      If txtItem.Text &lt;&gt; Nothing And txtQty.Text &lt;&gt; Nothing Then
  
          'create rows in the DataTable
          tblScItem.Rows.Add(itemArray())
      End If
  
      txtItem.Text = ""
      txtQty.Text = ""
  
  End Sub
  </code></pre>
  
  <p>This is how i declare my array:</p>
  
  <pre><code>Function itemArray() As String()
  
          itemArr(0) = ""
          itemArr(1) = txtItem.Text
          itemArr(2) = Form2.cbGondola.SelectedItem
          itemArr(3) = txtQty.Text
          itemArr(4) = DateTime.Now
          itemArr(5) = Form1.txtLoginId.Text
  
          Return itemArr
  End Function
  </code></pre>
  
  <p>I dont seem to do a proper check, help!</p>