0
Hello everyone I need to know how I can convert this code to public void
. Visual Studio shows error in variable and.
Error message: "The name 'e' does not exist in the Current context"
I just did it ctrl+c
and ctrl+v
of:
private void TextDisplay_KeyPress(object sender, KeyPressEventArgs e)
To:
public void Detect()
Down with 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();
}
The change you are reporting in the question should not cause any problems. Anyway only with this stretch it is not possible to identify what happens. Put more details about the error (message, line) and other relevant snippets.
– Maniero
@bigown I limit to making Ctrl c Ctrl v code above
private void TextDisplay_KeyPress(object sender, KeyPressEventArgs e)
forpublic void Detect()
made Ctrl s and appeared the error above– pekira
place public void Detect(Object Sender, Keypresseventargs and)
– Pablo Tondolo de Vargas
@Pablovargas Thank you for that as an answer
– pekira