Even finding the desired value in the register vector displays the message "TP não encontrado". I need that when the value is found it does not display the message that was not found.

for (int i = 0; i < cadastro_tp.Length; i++)
   if (txbTp.Text == cadastro_tp[i].tpv)
      txbCnpj.Text = cadastro_tp[i].cnpjv;
      txbNome.Text = cadastro_tp[i].nomev;
      cboCanal.Text = cadastro_tp[i].canalv;
      txbPortal.Text = cadastro_tp[i].portalv;
      txbEmpresa.Text = cadastro_tp[i].empv;
      txbEmail.Text = cadastro_tp[i].emailv;
      txbTel.Text = cadastro_tp[i].telv;
MessageBox.Show("TP não encontrado");
  • Já usei o else e o if else porém continua executando a mensagem Jan 20, 2019 at 14:24

1 Answer 1


I was able to solve by replacing the break to return.

Not the answer you're looking for? Browse other questions tagged or ask your own question.