When i am trying to store the values from excel sheets cells in an array (VB.NET) an error is shown.
Can you please comment such that the program runs successfully.
Thanx in Advance.
-------------------------------------------------------------------------
Next
End Sub
-----------------------------------------------------------------------------
Can you please comment such that the program runs successfully.
Thanx in Advance.
-------------------------------------------------------------------------
Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim Cell1, Cell2, Distance As Double
Dim XC(), YC(), Dist() As Double
Dim Row As Integer
xlsheet = xlBook.ActiveSheet()
For reading the cells (coordinates) from the excel sheet
and calculating the distance ...
This is without using Arrays and it is giving the
Distance successfully...
Cell1 = xlsheet.Cells(StRow, 6).value
Cell2 = xlsheet.Cells(StRow, 7).value
distance = Math.Sqrt(Cell1 * Cell1 + Cell2 * Cell2)
Msgbox(Distance)
Now i run a counter and read 10 cells from excel and storing
in an array and then calculating distance and
also storing that in an array... (It gives an error)
For row = 0 to 9
XC(Row) = xlsheet.Cells(Row, 6).value
The error is: Exception from HRESULT: 0x800A03EC
YC(Row) = xlsheet.Cells(Row, 7).value
Dist(Row) = Math.Sqrt(XC(Row) * XC(Row) + YC(Row) * YC(Row))
MsgBox(Dist(Row))
Next
End Sub
-----------------------------------------------------------------------------
Last edited by a moderator: