Jump to content
Xtreme .Net Talk

MKP

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by MKP

  1. 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. ------------------------------------------------------------------------- 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 -----------------------------------------------------------------------------
  2. How to read cell(1,1) and cell(1,2) from an excel workbook (c:/add.xls); worksheet (sheet1) and add the two numbers and display output in excel sheet (sheet 2 of c:/add.xls) cell(1,1)?
×
×
  • Create New...