PDA

View Full Version : سوال: چرا Return کار نمیکنه !!؟



AceBomBom
شنبه 04 آبان 1392, 01:11 صبح
وقتی text box مربوطه رو خالی میدم ولی بازم بقیه برنامه اجرا میشه

لطفا راهنماییم کنید :قلب:


public static void ms(string s)

{

if (s == "")
{
MessageBox.Show("خالی است");
return ;
}
}
private void CodeOz_textBox_KeyDown(object sender, KeyEventArgs e)
{
Int32 i;
if (e.KeyCode == Keys.Enter)
{
ms(this.CodeOz_textBox.Text);
i = Convert.ToInt32(this.CodeOz_textBox.Text);
try
{
// Code
}
catch (Exception ex)
{
Public_Class.Error_Message(ex.ToString());
}

}
}

danialafshari
شنبه 04 آبان 1392, 08:18 صبح
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
Int32 i;
if (e.KeyCode == Keys.Enter)
{
if (string.IsNullOrWhiteSpace(textBox1.Text))
{
MessageBox.Show("خالی است");
}
else
{
i = Convert.ToInt32(this.textBox1.Text);
try
{
// Code
}
catch (Exception ex)
{
//Public_Class.Error_Message(ex.ToString());
}
}

}