I have almost finished my project and i am stuck on one part of the code, an error comes up saying "embedded statement cannot be a declaration or labled statement" I dont know what that means (the error part of the code is coloured red in the code section underneathe)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;


  
namespace XBL_Bio_Maker
{
    public partial class Form1 : DevComponents.DotNetBar.Office2007Form
    {
        public Form1()
        {
            InitializeComponent();
           

        }

        private void Form1_Load(object sender, EventArgs e)
        {

            if (expandablePanel1.Expanded == true)
                 // Form1.Size == ("574, 660");
            List<Button>Buttons = null;

     

         
            List<string> values = null;


            values = new List<string>();

            values.Add("╋");

            values.Add("━");

            values.Add("┃");

            values.Add("┏");

            values.Add("┓");

            values.Add("┗");

            values.Add("┛");

            values.Add("┣");

            values.Add("┫");

            values.Add("┳");

            values.Add("┻");

            values.Add("");

            values.Add("☆");

            values.Add("←");

            values.Add("→");

            values.Add("↑");

            values.Add("↓");

            values.Add("①");

            values.Add("②");

            values.Add("③");

            values.Add("④");

            values.Add("⑤");

            values.Add("⑥");

            values.Add("⑦");

            values.Add("⑧");

            values.Add("⑨");

            values.Add("⑩");

            values.Add("™");

            values.Add("ㅎ");

            values.Add("♪");

            values.Add("ㅉ");

            values.Add("ㅈ");

            values.Add("♂");

            values.Add("♀");
        }

        private void buttonX1_Click(object sender, EventArgs e)
        {
           //styleManger1.ManagerStyle == DevComponents.DotNetBar.eStyle.Office2007Blue();
        }

        private void buttonX2_Click(object sender, EventArgs e)
        {
            //styleManger1.ManagerStyle == DevComponents.DotNetBar.eStyle.Office2007Black;
        }

        private void buttonX3_Click(object sender, EventArgs e)
        {
            // StyleManger1.ManagerStyle = DevComponents.DotNetBar.eStyle.Office2007Silver;
            //Me.Office2007ColorTable = DevComponents.DotNetBar.Rendering.eOffic e2007ColorScheme.Black;
        }

        private void buttonX4_Click(object sender, EventArgs e)
        {
            // StyleManger1.ManagerStyle = DevComponents.DotNetBar.eStyle.Office2007VistaGlass;
        }

        private void buttonX15_Click(object sender, EventArgs e)
        {
            List<TextBox> boxes = new List<TextBox>() { textBox1, textBox2, textBox3, textBox4, textBox5, textBox6, textBox7, textBox8, textBox9, textBox10, textBox11, textBox12, textBox13, textBox14, textBox15, textBox16, textBox17, textBox18, textBox19, textBox20, textBox21, textBox22, textBox23, textBox24, textBox25, textBox26, textBox27, textBox28, textBox29, textBox30, textBox31, textBox32, textBox33, textBox34, textBox35, textBox36, textBox37, textBox38, textBox39, textBox40, textBox41, textBox42, textBox43, textBox44, textBox45, textBox46, textBox47, textBox48, textBox49, textBox50, textBox51, textBox52, textBox53, textBox54, textBox55, textBox56, textBox57, textBox58, textBox59, textBox60, textBox61, textBox62, textBox63, textBox64, textBox65, textBox66, textBox67, textBox68, textBox69, textBox70, textBox71, textBox72, textBox73, textBox74, textBox75, textBox76, textBox77, textBox78, textBox79, textBox80, textBox81, textBox82, textBox83, textBox84, textBox85, textBox86, textBox87, textBox88, textBox89, textBox90, textBox91, textBox92, textBox93, textBox94, textBox95 ,textBox96 ,textBox97 ,textBox98 ,textBox99 ,textBox100 ,textBox101 ,textBox102 ,textBox103 ,textBox104 ,textBox105 ,textBox106 ,textBox107 ,textBox108 ,textBox109 ,textBox110,textBox111 ,textBox112 ,textBox113 ,textBox114 ,textBox115 ,textBox116,textBox117 ,textBox118 ,textBox119 ,textBox120 ,textBox121 ,textBox122 ,textBox123 ,textBox124 ,textBox125 ,textBox126 ,textBox127 ,textBox128 ,textBox129 ,textBox130 ,textBox131 ,textBox132 ,textBox133 ,textBox134 ,textBox135 ,textBox136 ,textBox137 ,textBox138 ,textBox139 ,textBox140 ,textBox141 ,textBox142 ,textBox143 ,textBox144 ,textBox145 ,textBox146 ,textBox147 ,textBox148 ,textBox149 ,textBox150 ,textBox151 ,textBox152 ,textBox153 ,textBox154 ,textBox155 ,textBox156 ,textBox157 ,textBox158 ,textBox159 ,textBox160 ,textBox161 ,textBox162 ,textBox163 ,textBox164 ,textBox165 ,textBox166 ,textBox167 ,textBox168 ,textBox169 ,textBox170};
            
var query = from textBoxX in boxes

select textBox1.Text;

 

string combinedText = string.Join(string.Empty, query.ToArray());
        }

        private void buttonX23_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process process = new System.Diagnostics.Process();
            process.StartInfo.FileName = ("http://Xbox.com");
            process.Start();
        }

        private void buttonX24_Click(object sender, EventArgs e)
        {
             //controls.Where(control => control is TextBox).ToList().ForEach(tb => tb.Text = string.Empty);
        }

        private void buttonX16_Click(object sender, EventArgs e)
        {
           
var controls = this.Controls.Cast<Control>();

string[] texts = (from control in controls

where control is TextBox

select control.Text).ToArray();

StringBuilder builder = new StringBuilder();

int columns = 10;

int rows = 17;

for (int i = 0; i < rows; i++)

{

builder.Append(string.Join(string.Empty, texts, i * columns, columns));

builder.Append("\n");

}
     SaveFileDialog SaveFile = new SaveFileDialog();
     SaveFile.FileName = "My Bio Creation";
     SaveFile.Filter = "Text Files (*.txt)|*.txt";
     SaveFile.Title = "Save";
     SaveFile.ShowDialog();
     try {
       System.IO.StreamWriter Write = new System.IO.StreamWriter(SaveFile.FileName);
       //Write.Write(textBox1, textBox2, textBox3, textBox4, textBox5, textBox6, textBox7, textBox8, textBox9, textBox10, textBox11, textBox12, textBox13, textBox14, textBox15, textBox16, textBox17, textBox18, textBox19, textBox20, textBox21, textBox22, textBox23, textBox24, textBox25, textBox26, textBox27, textBox28, textBox29, textBox30, textBox31, textBox32, textBox33, textBox34, textBox35, textBox36, textBox37, textBox38, textBox39, textBox40, textBox41, textBox42, textBox43, textBox44, textBox45, textBox46, textBox47, textBox48, textBox49, textBox50, textBox51, textBox52, textBox53, textBox54, textBox55, textBox56, textBox57, textBox58, textBox59, textBox60, textBox61, textBox62, textBox63, textBox64, textBox65, textBox66, textBox67, textBox68, textBox69, textBox70, textBox71, textBox72, textBox73, textBox74, textBox75, textBox76, textBox77, textBox78, textBox79, textBox80, textBox81, textBox82, textBox83, textBox84, textBox85, textBox86, textBox87, textBox88, textBox89, textBox90, textBox91, textBox92, textBox93, textBox94, textBox95, textBox96, textBox97, textBox98, textBox99, textBox100, textBox101, textBox102, textBox103, textBox104, textBox105, textBox106, textBox107, textBox108, textBox109, textBox110, textBox111, textBox112, textBox113, textBox114, textBox115, textBox116, textBox117, textBox118, textBox119, textBox120, textBox121, textBox122, textBox123, textBox124, textBox125, textBox126, textBox127, textBox128, textBox129, textBox130, textBox131, textBox132, textBox133, textBox134, textBox135, textBox136, textBox137, textBox138, textBox139, textBox140, textBox141, textBox142, textBox143, textBox144, textBox145, textBox146, textBox147, textBox148, textBox149, textBox150, textBox151, textBox152, textBox153, textBox154, textBox155, textBox156, textBox157, textBox158, textBox159, textBox160, textBox161, textBox162, textBox163, textBox164, textBox165, textBox166, textBox167, textBox168, textBox169, textBox170);
        Write.Close();
     }
     catch (Exception ex) {
        
     }
 
        }

        private void expandablePanel1_Click(object sender, EventArgs e)
        {
            
        }

        private void buttonX21_Click(object sender, EventArgs e)
        {

        }

    }

}

Recommended Answers

All 4 Replies

Try

List<Button> buttons = null;

Still no luck

You have an if statement without surrounding brackets, which means the next line of code following the if statement is the single embedded statement of the if condition.

You have commented out the line directly following the if statement. That makes the next statement the single embedded statement of the if condition.

I can't imagine that's what you intended, but if it is, all you need to do is wrap the code within brackets like the following and it's all legal again.

if (true)
{
    List<int> list = new List<int>();
}

The code still isn't useful, but it's legal.

But I imagine you want to have your list of buttons around regardless of the if statement. If you do not have anything you want to accomplish upon the if condition evaluating to true, you want to either comment out the if statement entirely or provide put opening and closing brackets around the line of code that you have commented out.

thx it worked

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.