title: How do I use the Tag property with forms and code in VB 2012?
body: <p>I am writing a program using a database for customers and technicians. The main form (CustomerIncidents) has a toolstripbutton that opens a different form to (SearchByState) where the user inputs a state code and looks for any incidents.</p>
  
  <p>If the user clicks into one of the datagrid cells I want that customers information to be stored in the TAG so that when the form is closed using the OK button that it will show back up in the main form (CustomerIncidents).</p>
  
  <p><strong>Edited 03/11/14 12:21pm</strong></p>
  
  <p>The problem is in the Main Form. When I click the OK button in the Second Form it tries to convert the DialogResult Button to a String. I can't figure out how to fix it.</p>
  
  <p><strong>Customer Form (Main Form) Opens to Secondary Form</strong></p>
  
  <pre><code>Private Sub btnOpenState_Click(ByVal sender As System.Object, 
  ByVal e As System.EventArgs) Handles btnOpenState.Click
          Dim frmSearchState As New FindCustomer
   -----&gt;&gt;Dim selectedButton As DialogResult = frmSearchState.ShowDialog()
          If selectedButton = Windows.Forms.DialogResult.OK Then
              CustomerIDToolStripTextBox.Text = frmSearchState.Tag.ToString
          End If'
  </code></pre>
  
  <p><strong>Search By State Form (Secondary Form) Or "Child Form"</strong></p>
  
  <pre><code>Private Sub btnOk_Click(message As String, ByVal e As DataGridViewCellEventArgs) Handles btnOk.Click
  
      message = CustomersDataGridView.Rows(e.RowIndex).Cells(e.ColumnIndex).Value.ToString
  
      Me.Tag = message
      Me.DialogResult = DialogResult.OK
  End Sub
  </code></pre>