i'm new to c# after some time in assembly, and a bit of c++.
i'm trying to examine 2 cells and report back depending on their contents.
i want to test A11

  • if it is empty - exit
  • else test B11
  • if thats empty then return D11, do the same for A12, B12 ....
  • else exit

i'm trying to start off with just getting it working for A11, B11 ...

string result1 = (xlWorkSheet.get_Range("A11", "A11").Value2.ToString());
        if (result1 != "") 
        {    string result2 = (xlWorkSheet.get_Range("B11", "B11").Value2.ToString());
            if (result2 "")

            string shutdown = (xlWorkSheet.get_Range("D11", "D11").Value2.ToString());

i cant seem to find the right syntax to get it working.

help much appreciated. thanks

spotted my error in the above. will try to set up a while statement loop to increment the row number.

here is my code so far

int Indexnum = 11;
            string Index1 = ("A" + Indexnum);
            string Index2 = ("B" + Indexnum);
            string Index3 = ("D" + Indexnum);

                string result1 = (xlWorkSheet.get_Range(Index1, Index1).Value2.ToString());
                if (result1 != "")
                    string result2 = (xlWorkSheet.get_Range(Index2, Index2).Value2.ToString());
                    if (result2 != "")
                        labshutdown.Text = "";
                        string shutdown = (xlWorkSheet.get_Range(Index3, Index3).Value2.ToString());
                        labshutdown.Text = shutdown;


i want to run this process until cell A(Indexnum) is empty while incrementing indexnum. I tried to set up a while statement based on result1, but i kept getting the message that it was out of context. can somebody point me in the right direction please. thanks