Solved

Easy syntax fixing. C#

Posted on 2008-06-10
7
1,253 Views
Last Modified: 2013-12-17
I converted some code :
cellvalue = (Microsoft.Office.Interop.Excel.Range)inputRange.Cells(rowCount, pricesColumn);
                    if (Strings.Len(cellvalue.Value) > 0)
                    {
                        if (cellvalue.Value.ToString == "Stones" | cellvalue.Value.ToString == "Tough")
                        {
                            // all prices have been read
                            currRow = rowCount + 1;
                            // skip a row to where the discounts are
                            break; // TODO: might not be correct. Was : Exit For
                        }
                        Price = (double)cellvalue.Value;
                        cellvalue = (Microsoft.Office.Interop.Excel.Range)inputRange.Cells(rowCount, 15);
                        gradeName = cellvalue.Value.ToString;
                        Insert_Price_List_Detail(gradeName, Price);
                        // insert the prices
                    }

Error      1      No overload for method 'Open' takes '1' arguments      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      46      1      InitialPriceReportingSpreadsheet
Error      2      'Microsoft.Office.Interop.Excel.Range.Cells' is a 'property' but is used like a 'method'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      70      82      InitialPriceReportingSpreadsheet
Error      3      The name 'Strings' does not exist in the current context      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      71      25      InitialPriceReportingSpreadsheet
Error      4      Property, indexer, or event 'Value' is not supported by the language; try directly calling accessor methods 'Microsoft.Office.Interop.Excel.Range.get_Value(object)' or 'Microsoft.Office.Interop.Excel.Range.set_Value(object, object)'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      71      47      InitialPriceReportingSpreadsheet
Error      5      Property, indexer, or event 'Value' is not supported by the language; try directly calling accessor methods 'Microsoft.Office.Interop.Excel.Range.get_Value(object)' or 'Microsoft.Office.Interop.Excel.Range.set_Value(object, object)'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      73      39      InitialPriceReportingSpreadsheet
Error      6      Property, indexer, or event 'Value' is not supported by the language; try directly calling accessor methods 'Microsoft.Office.Interop.Excel.Range.get_Value(object)' or 'Microsoft.Office.Interop.Excel.Range.set_Value(object, object)'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      73      78      InitialPriceReportingSpreadsheet
Error      7      Property, indexer, or event 'Value' is not supported by the language; try directly calling accessor methods 'Microsoft.Office.Interop.Excel.Range.get_Value(object)' or 'Microsoft.Office.Interop.Excel.Range.set_Value(object, object)'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      80      51      InitialPriceReportingSpreadsheet
Error      8      'Microsoft.Office.Interop.Excel.Range.Cells' is a 'property' but is used like a 'method'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      81      86      InitialPriceReportingSpreadsheet
Error      9      Property, indexer, or event 'Value' is not supported by the language; try directly calling accessor methods 'Microsoft.Office.Interop.Excel.Range.get_Value(object)' or 'Microsoft.Office.Interop.Excel.Range.set_Value(object, object)'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      82      47      InitialPriceReportingSpreadsheet


from vb.net but
i have errors.

can someone help me out.
0
Comment
Question by:mathieu_cupryk
  • 5
  • 2
7 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 21756411
this line:
cellvalue = (Microsoft.Office.Interop.Excel.Range)inputRange.Cells(rowCount, pricesColumn);
should be:
cellvalue = ((Microsoft.Office.Interop.Excel.Range)inputRange).Cells(rowCount, pricesColumn);

this line:
if (cellvalue.Value.ToString == "Stones" | cellvalue.Value.ToString == "Tough")
should be:
if (cellvalue.Value.ToString() == "Stones" | cellvalue.Value.ToString() == "Tough")

this line:
cellvalue = (Microsoft.Office.Interop.Excel.Range)inputRange.Cells(rowCount, 15);
should be:
cellvalue = ((Microsoft.Office.Interop.Excel.Range)inputRange).Cells(rowCount, 15);

this line:
gradeName = cellvalue.Value.ToString;
should be:
gradeName = cellvalue.Value.ToString();
                       
                       
0
 

Author Comment

by:mathieu_cupryk
ID: 21756424
Error      2      'Microsoft.Office.Interop.Excel.Range.Cells' is a 'property' but is used like a 'method'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      79      84      InitialPriceReportingSpreadsheet

   cellvalue = ((Microsoft.Office.Interop.Excel.Range)inputRange).Cells(rowCount, pricesColumn);

i am stuck on this.
0
 

Author Comment

by:mathieu_cupryk
ID: 21756431
Error      4      Property, indexer, or event 'Value' is not supported by the language; try directly calling accessor methods 'Microsoft.Office.Interop.Excel.Range.get_Value(object)' or 'Microsoft.Office.Interop.Excel.Range.set_Value(object, object)'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      81      47      InitialPriceReportingSpreadsheet

 if (cellvalue.Value.ToString() == "Stones" | cellvalue.Value.ToString() == "Tough")
                       
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:mathieu_cupryk
ID: 21756439
Error      9      'Microsoft.Office.Interop.Excel.Range.Cells' is a 'property' but is used like a 'method'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      92      86      InitialPriceReportingSpreadsheet
 cellvalue = ((Microsoft.Office.Interop.Excel.Range)inputRange).Cells(rowCount, 15);
                       
another error
0
 

Author Comment

by:mathieu_cupryk
ID: 21756445
Error      9      Property, indexer, or event 'Value' is not supported by the language; try directly calling accessor methods 'Microsoft.Office.Interop.Excel.Range.get_Value(object)' or 'Microsoft.Office.Interop.Excel.Range.set_Value(object, object)'      C:\Users\Aministrator\Desktop\InitialPriceReporting\InitialPriceReporting\DotNet\InitialPriceReportingSpreadsheet\Program.cs      92      47      InitialPriceReportingSpreadsheet
gradeName = cellvalue.Value.ToString();
0
 

Author Comment

by:mathieu_cupryk
ID: 21756514
I got some done.
 if (Strings.Len(cellvalue.Value2) > 0)
                    {
                        if (cellvalue.Value2.ToString() == "Stones" | cellvalue.Value2.ToString() == "Tough")
                        {
                            // all prices have been read
                            currRow = rowCount + 1;
                            // skip a row to where the discounts are
                            break; // TODO: might not be correct. Was : Exit For
                        }
                        Price = Int32.Parse(cellvalue.Value2.ToString());

                        cellvalue.Value2 = Cells[rowCount, 15];
                        gradeName = cellvalue.Value2.ToString();

                        Insert_Price_List_Detail(gradeName, Price);
                        // insert the prices
                    }

is this ok?
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 21756539
do you have compiler error messages?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now