*** آشنایی و گفتگوی بچه های کامپیوتر....***

C#.net

اخراجی موقت
اسمی که توی پنجره properties هست و اسم فرم که در solution eplorer هست چه ارتباطی با هم دارن؟
 

C#.net

اخراجی موقت
private void button1_Click(object sender, EventArgs e)

{if textBox1.Text=="admin"
Form2 f2 = new Form2();
f2.Show();
}
}
}

Error 2 ) expected f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 21 35 ali2
Error 3 Embedded statement cannot be a declaration or labeled statement f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 22 13 ali2
Error 1 Syntax error, '(' expected f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 21 13 ali2
 

C#.net

اخراجی موقت
private void button1_Click(object sender, EventArgs e)

{if (textBox1.Text=="admin")
Form2 f2 = new Form2();f2.Show();


Error 1 Embedded statement cannot be a declaration or labeled statement f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 22 13 ali2
 

C#.net

اخراجی موقت
private void button1_Click(object sender, EventArgs e)

{if (textBox1.Text=="admin")
Form2 f2 = new Form2();f2.Show();


}


Error 1 Embedded statement cannot be a declaration or labeled statement f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 22 13 ali2
 

farshad2bakhsheh

عضو جدید
سلام تازه اومدم خوش اومدم ......
خوشحال میشم هم دوست خوب داشته باشم هم دوست خوبی براتون باشم
و از علمتون هم بهره ببرم
ممنون همتون فعلا
 

nafis...

مدیر بازنشسته
اسمی که توی پنجره properties هست و اسم فرم که در solution eplorer هست چه ارتباطی با هم دارن؟


private void button1_Click(object sender, EventArgs e)

{if textBox1.Text=="admin"
Form2 f2 = new Form2();
f2.Show();
}
}
}

Error 2  ) expected f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 21 35 ali2
Error 3 Embedded statement cannot be a declaration or labeled statement f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 22 13 ali2
Error 1 Syntax error, '(' expected f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 21 13 ali2


این شرط جلوی if رو تو پرانتز نوشتی؟
 

C#.net

اخراجی موقت
یه بار دیگه کدت رو برام بذار
مثل پست من تو تگ های کد بذار تا واضح تر باشه
namespace ali2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}


private void button1_Click(object sender, EventArgs e)

{if (textBox1.Text=="admin")
form2 f2 = new Form2();f2().Show();


}
}
}


ارور :
Error 1 Embedded statement cannot be a declaration or labeled statement f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 22 2 ali2
 

nafis...

مدیر بازنشسته
namespace ali2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}


private void button1_Click(object sender, EventArgs e)

{if (textBox1.Text=="admin")
form2 f2 = new Form2();f2().Show();


}
}
}


ارور :
Error 1 Embedded statement cannot be a declaration or labeled statement f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 22 2 ali2
مشکلت به خاطر این است که دستور if شما ‍Block of Code ندارد یعنی ‍{ } برایش ایجاد نکردی.
 

C#.net

اخراجی موقت
namespace ali2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}


private void button1_Click(object sender, EventArgs e)

{if (textBox1.Text=="admin")
form2 f2 = new Form2();f2().Show();


}
}
}


ارور :
Error 1 Embedded statement cannot be a declaration or labeled statement f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 22 2 ali2
پس این چیه؟
 

nafis...

مدیر بازنشسته
اون پرانتزی که باز و بسته شده ماله
private void button1_Click(object sender, EventArgs e)
این هست
دقت کن تو کدت
کد:
[COLOR=#333333][I]private void button1_Click(object sender, EventArgs e)[/I][/COLOR]

[COLOR=#ff0000][I][SIZE=5]{
[/SIZE][/I][/COLOR][COLOR=#333333][I]if (textBox1.Text=="admin")
[/I][/COLOR]}
[COLOR=#333333][I]form2 f2 = new Form2();
f2().Show();[/I][/COLOR]
{

[SIZE=5][COLOR=#333333][I][COLOR=#ff0000]}[/COLOR][/I][/COLOR][/SIZE]
کد من رو ببین اصلاح کردم
 

C#.net

اخراجی موقت
namespace ali2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}


private void button1_Click(object sender, EventArgs e)

{
if (textBox1.Text=="admin")
}
form2 f2 = new Form2();
f2().Show();
{


}
}
}



ارور
Error 2 ; expected f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 25 5 ali2
Error 8 ; expected f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 23 2 ali2
Error 7 } expected f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 23 2 ali2
Error 6 Invalid expression term '}' f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 23 1 ali2
Error 4 Invalid token '{' in class, struct, or interface member declaration f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 26 1 ali2
Error 1 Method must have a return type f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 25 1 ali2
Error 3 Method must have a return type f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 25 6 ali2
Error 9 Only assignment, call, increment, decrement, and new object expressions can be used as a statement f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 22 27 ali2
Error 10 The type or namespace name 'form2' could not be found (are you missing a using directive or an assembly reference?) f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 24 1 ali2
Error 5 Type or namespace definition, or end-of-file expected f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 30 1 ali2
 

nafis...

مدیر بازنشسته
namespace ali2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}


private void button1_Click(object sender, EventArgs e)

{
if (textBox1.Text=="admin")
}
form2 f2 = new Form2();
f2().Show();
{


}
}
}



ارور
Error 2 ; expected f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 25 5 ali2
Error 8 ; expected f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 23 2 ali2
Error 7 } expected f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 23 2 ali2
Error 6 Invalid expression term '}' f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 23 1 ali2
Error 4 Invalid token '{' in class, struct, or interface member declaration f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 26 1 ali2
Error 1 Method must have a return type f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 25 1 ali2
Error 3 Method must have a return type f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 25 6 ali2
Error 9 Only assignment, call, increment, decrement, and new object expressions can be used as a statement f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 22 27 ali2
Error 10 The type or namespace name 'form2' could not be found (are you missing a using directive or an assembly reference?) f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 24 1 ali2
Error 5 Type or namespace definition, or end-of-file expected f:\ali7\visual studio 2010\Projects\ali2\ali2\Form1.cs 30 1 ali2
این قد عجله نکن برای گذاشت{}
ببین کجا پرانتز باز شده کجا ها بسته
کد:
namespace ali2{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}




private void button1_Click(object sender, EventArgs e)


{
if (textBox1.Text=="admin")
{
    form2 f2 = new Form2();
    f2().Show();
}
}
 }
}
کد من رو ببین من اصلاحش کردم
همش تو پرانتز باز و بسته مشکل داری:surprised:
داری کپی میکنی درست کپی کن
اگه نتونستی
برنامتو آپلود کن من برات اصلاحش کنم
 

joghd123

عضو جدید
کاربر ممتاز
راه حل اینه که هر چیزی که پرانتزش وا میشه همون اول پرانتزشو ببنده و کدهارو داخل بنویسه .اینجوری مشکلی پیش نمیاد.:cool:
 

C#.net

اخراجی موقت
این قد عجله نکن برای گذاشت{}
ببین کجا پرانتز باز شده کجا ها بسته
کد:
namespace ali2{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}




private void button1_Click(object sender, EventArgs e)


{
if (textBox1.Text=="admin")
{
    form2 f2 = new Form2();
    f2().Show();
}
}
 }
}
کد من رو ببین من اصلاحش کردم
همش تو پرانتز باز و بسته مشکل داری:surprised:
داری کپی میکنی درست کپی کن
اگه نتونستی
برنامتو آپلود کن من برات اصلاحش کنم
مشاهده پیوست ali2.rar
 

nafis...

مدیر بازنشسته
اولا این که فایلت باز نمیشد
دوما مشکلش رو فهمیدم:
به جای این کد
کد:
    f2().Show();
که اشتباه هست باید کد زیر رو بنویسی
کد:
    f2.Show();
مشکلش کجا بود؟ بعد از f2 نباید پرانتز بزاری
وقتی رسیدی به مفهوم کلاسها با اینا آشنا میشی
 

Similar threads

بالا