hello pals:
I now encounter a problem. I wrote a procedure before to read datas from Excel in VB6.
But when I run it in vb.net. It shows that
Excel.Application
Excel.Workbook
Excel.Worksheet
are not defined. Can anybody tell me that what's the equal definition in VB.net for the above three statement?
Any hint will be very appriciated!
I now encounter a problem. I wrote a procedure before to read datas from Excel in VB6.
VB.NET:
Private Sub Form_Load()
Dim X1 As Integer
Dim X2 As Integer
Dim Y1 As Integer
Dim Y2 As Integer
Dim oXLApp As Excel.Application 'Declare the object variables
Dim oXLBook As Excel.Workbook
Dim oXLSheet As Excel.Worksheet
Set oXLApp = New Excel.Application 'Create a new instance of Excel
Set oXLBook = oXLApp.Workbooks.Open("D:\New Folder\Book1") 'Open an existing workbook
Set oXLSheet = oXLBook.Worksheets(1) 'Work with the first worksheet
Dim my_variable As String
my_variable = "hello"
oXLSheet.Cells(2, 1).Value = my_variable
X1 = oXLSheet.Cells(1, 1).Value
Y1 = oXLSheet.Cells(1, 2).Value
X2 = oXLSheet.Cells(1, 3).Value
Y2 = oXLSheet.Cells(1, 4).Value
oXLApp.Visible = True 'Show it to the user
Set oXLSheet = Nothing 'Disconnect from all Excel objects (let the user take over)
Set oXLBook = Nothing
Set oXLApp = Nothing
End Sub
Excel.Application
Excel.Workbook
Excel.Worksheet
are not defined. Can anybody tell me that what's the equal definition in VB.net for the above three statement?
Any hint will be very appriciated!