quarta-feira, 5 de outubro de 2016
05-10-16 ArrayObjeto
namespace _05_10_16_ArrayObjeto
{
public partial class frm_contador : Form
{
private int conter;
private string[] numbers = new string[6];
public frm_contador()
{
InitializeComponent();
numbers[0] = "zero";
numbers[1] = "um";
numbers[2] = "dois";
numbers[3] = "três";
numbers[4] = "quatro";
}
private void btnNext_Click(object sender, EventArgs e)
{
lblOutput.Text = numbers[conter];
conter++;
if (conter == 6)
{
conter = 0;
}
}
private void btnSair_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
05-10-16 Substring
namespace _05_10_16_SubString
{
public partial class frm_substring : Form
{
public frm_substring()
{
InitializeComponent();
}
private void btnProcurar_Click(object sender, EventArgs e)
{
int i, qtd;
string aux;
qtd = 0;
aux = txtFrase.Text;
aux = aux.ToUpper();
for ( i = 0; i < aux.Length; i++)
if (aux.Substring(i, 1) == txtLetra.Text.ToUpper())
{
qtd++;
}
MessageBox.Show("A letra aparece " + Convert.ToString(qtd) + " vezes.");
}
private void btnLimpar_Click(object sender, EventArgs e)
{
txtLetra.Text = "";
txtFrase.Text = "";
}
private void Sair_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
Assinar:
Postagens (Atom)