Solved

Easy syntax fixing. C#

Posted on 2008-06-10
7
1,266 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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