Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Convert C# to vb.net urgent?

Posted on 2007-03-29
2
Medium Priority
?
211 Views
Last Modified: 2010-04-16
try
    {
        DataTable dt = new DataTable();
        objDB = new DatabaseToExcel.DB(ConnectionString);
        dt = objDB.runQuery(query);
        ctl_progress.Visible = true;
        ctl_progress.Minimum = 1;
        ctl_progress.Maximum = dt.Rows.Count + 1;
        ctl_progress.Value = 1;
        //This is to access the first work sheet of your application
        sheet = (Excel.Worksheet)book.Worksheets[1];
        sheet.Name = "SampleExcel";
        for(int i = 1 ; i <= dt.Rows.Count ; i++)
        {
            for(int j = 1 ; j <= dt.Columns.Count ; j++ )
            {
                // This is to add the Data which retrieved from
                // the database into your Excel Sheet.
                ((Excel.Range)sheet.Cells[i,j]).Value2
                                   = dt.Rows[i-1].ItemArray[j-1].ToString();
                //dt.Rows[i-1].ItemArray[j-1].ToString()--> This will retrieve
                // data from your datatable's
                //(i-1)th rows (j-1)st column
            }
            ctl_progress.Value += 1;
        }
        MessageBox.Show("Your Process Completed Successfully");
        ctl_progress.Visible = false;
    }
    catch(Exception e1)
    {
        MessageBox.Show(e1.Message);
    }
0
Comment
Question by:mathieu_cupryk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 18821555
Should be...

    Try
        Dim dt As New DataTable()
        objDB = New DatabaseToExcel.DB(ConnectionString)
        dt = objDB.runQuery(query)
        ctl_progress.Visible = True
        ctl_progress.Minimum = 1
        ctl_progress.Maximum = dt.Rows.Count + 1
        ctl_progress.Value = 1
        ' This is to access the first work sheet of your application
        sheet = CType(book.Worksheets(1), Excel.Worksheet)
        sheet.Name = "SampleExcel"
        For i As Integer = 1 to dt.Rows.Count
            For j As Integer = 1 to dt.Columns.Count
                ' This is to add the Data which retrieved from
                ' the database into your Excel Sheet.
                CType(sheet.Cells(i,j), Excel.Range).Value2
                                   = dt.Rows(i-1).ItemArray(j-1).ToString()
                'dt.Rows[i-1].ItemArray[j-1].ToString()--> This will retrieve
                ' data from your datatable's
                '(i-1)th rows (j-1)st column
            Next
            ctl_progress.Value = ctl_progress.Value + 1
        Next
        MessageBox.Show("Your Process Completed Successfully")
        ctl_progress.Visible = False
    Catch e1 As Exception
        MessageBox.Show(e1.Message)
    End Try
0
 
LVL 2

Expert Comment

by:empoalp
ID: 18822533
You have an automatic C# to vb.net converter in this link.
http://www.kamalpatel.net/ConvertCSharp2VB.aspx
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

730 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