Click here to Skip to main content
14,937,132 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Function tired_of_name_test()

Dim oExcel As Excel.Application                                                                         ' Excel Application
Set oExcel = New Excel.Application                                                                    ' Start it
oExcel.Workbooks.Open "YOUR_EXCEL_FILE.XLSX"                                       ' **** CHANGE NAME HERE **** Open it.

on error goto kill_task
Col = ListBox1.ColumnCount                                                         ' Number of Columns
Row = ListBox1.ListCount                                                              ' Number of Rows


For C = 1 to Ubound(Col)                                                              ' For each Column
    For L = 1 to Ubound(Row)                                                         ' in Each Line
         oExcel.Cells(j,i) = Listbox1.List(j - 1, i - 1)                             ' Write the value for Line, Columns
    next L                                                                                         ' Next Line
next C                                                                                            ' Next Col


       oExcel.ActiveWorkbook.Save                       ' Save
       oExcel.Workbooks(1).Close                         ' Close Workbook
       oExcel.Application.Quit                                 ' Close Application
exit function

kill_task:
      oExcel.ActiveWorkbook.Save                       ' Save
      oExcel.Workbooks(1).Close                         ' Close Workbook
      oExcel.Application.Quit                                 ' Close Application
end function


What I have tried:

Am new to C# language and i have not yet finished learning the basics.
Tried but couldn't finish it.


The code is looks it can compute the right out put but is not compatible with the C# am using.
Posted
Updated 20-Aug-18 0:44am
v2
Comments
Graeme_Grant 20-Aug-18 6:21am
   
You know that we don't work for you right? Have you read the FAQ? If you are looking for someone to work for you, go to: Hire Freelancers & Find Freelance Jobs Online - Freelancer[^]
Jochen Arndt 20-Aug-18 6:24am
   
There are many examples in the web on exporting listbox data to Excel with C#.
So why do you want to use a VB solution and convert it to C#?

Note also that this site is not providing code conversion services. We will help with specific questions. So you might update your answer, show what you have tried, and explain what is not working. But again, it is better to use example code that is already written in the required language.

1 solution

No. We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.
And to be honest, converted code is generally pretty rubbish: it doesn't use the target language correctly.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900