Hello everyone, I wondered how I can convert this code to public void
. Visual Studio reports an error in the and variable.
Error message: "The name 'and' does not exist in the current context"
I just made ctrl+c
and ctrl+v
of:
private void TextDisplay_KeyPress(object sender, KeyPressEventArgs e)
To:
public void Detect()
Below the body of my method:
if (e.KeyChar == 49 || e.KeyChar == 50 || e.KeyChar == 51 || e.KeyChar == 52 || e.KeyChar == 53 || e.KeyChar == 54 || e.KeyChar == 55 || e.KeyChar == 56 || e.KeyChar == 57 || e.KeyChar == 58)
{
TextDisplay.Text = TextDisplay.Text + e.KeyChar.ToString();
}
//Detetor da tecla Equal
if (e.KeyChar == 61)
{
Equal();
}
//Detetor da tecla Multi
if (e.KeyChar == 42)
{
Multi();
}
//Detetor da tecla Plus
if (e.KeyChar == 43)
{
Plus();
}
//Detetor da tecla Divisão
if (e.KeyChar == 47)
{
Divisão();
}
//Detetor da tecla less
if (e.KeyChar == 45)
{
Less();
}
//DetetoR da tecla backspace
if (e.KeyChar == 8)
{
if (TextDisplay.Text == "")
{
System.Media.SystemSounds.Beep.Play();
}
else
{
if (TextDisplay.Text.Length == 1)
{
TextDisplay.Text = "";
}
else
{
TextDisplay.Text = TextDisplay.Text.Substring(0, TextDisplay.Text.Length - 1);
}
}
}
//Detetor da tecla enter
if (e.KeyChar == 13)
{
Equal();
}
//Detetor da tecla Esc
if (e.KeyChar == 27)
{
Clear();
}