title: Variable 'Name' is used before it has been assigned a value
body: <p>hello i wanted to make a chat and i searched on the internet and i finaly found something that may work. but now i get an error at name it says Variable Name is used before it has assigned a value</p>
  
  <p>Code:</p>
  
  <pre><code>Public Sub findForm1()
  
      If Trim(Mid(My.Forms.Private1.Text, My.Forms.Private1.Text.Length - 2)) = formNo Then
          My.Forms.Private1.RichTextBox1.Text = My.Forms.Private1.RichTextBox1.Text &amp; poruka + vbCrLf
  
      ElseIf Trim(Mid(My.Forms.Private2.Text, My.Forms.Private2.Text.Length - 2)) = formNo Then
          My.Forms.Private2.RichTextBox1.Text = My.Forms.Private2.RichTextBox1.Text &amp; poruka + vbCrLf
  
      Else
          If My.Forms.Private1.Visible = False Then
              Dim name As String
              For i As Integer = 1 To poruka.Length
                  If Mid(poruka, i, 2) = ": " Then
                      Exit For
  
                      name = name &amp; Mid(poruka, i, 1)
                  End If
              Next
              My.Forms.Private1.Show()
              My.Forms.Private1.Text = Trim(name) &amp; "   " &amp; br
              My.Forms.Private1.RichTextBox1.Text = My.Forms.Private1.RichTextBox1.Text &amp; poruka + vbCrLf
          Else
              Dim name As String
              For i As Integer = 1 To poruka.Length
                  If Mid(poruka, i, 2) = ": " Then
                      Exit For
                  End If
                  name = name &amp; Mid(poruka, i, 1)
              Next
              My.Forms.Private2.Show()
              My.Forms.Private2.Text = Trim(name) &amp; "   " &amp; br
              My.Forms.Private2.RichTextBox1.Text = My.Forms.Private2.RichTextBox1.Text &amp; poruka + vbCrLf
          End If
      End If
  
      formNo = Nothing
      poruka = Nothing
  
  End Sub
  </code></pre>
  
  <p>how can i fix this error??
  i already tried to move the end if and change some else to end if.
  but still not find the right code PLEAS HELP.</p>