Proplem with implementation of Range's Item property

W

wasteheap

Take the following VB.NET code.

-------------------------------
Dim ss as New OWC10.Spreadsheet

For i As Integer = 1 To 10
ss.ActiveSheet.Cells.Item(i).Value = "x"
Next
-------------------------------

The resulting spreadsheet has x's across the first 10 cells of the
first row.

According to the MS documentation:

-------------------------------
Item property as it applies to the Range object.

Returns a Range object that represents a specific cell within the
specified range of cells.

expression.Item(RowIndex, ColumnIndex)

expression Required. An expression that returns a Range object.

RowIndex Required Variant. The row index of the cell that you want
to return.

ColumnIndex Optional Variant. The column index of the cell that you
want to return.
-------------------------------

Also in Visual Studio, I see
Item(RowIndex As Object, [ColumnIndex As Object])
pop up as I type.

This tells me that
.item(2)
should be equivalent to
.range(.item(2, 1), .item(2, maxCol)) 'Entire 2nd row
or at least
.item(2, 1) 'First cell in 2nd row

HOWEVER it is apparently implemented as
.item(1, 2) '2nd cell of *1st* row
but rowIndex = 2 !!!!

What gives???
 
W

wasteheap

P.S. Maybe using .Value is a bad example, since setting the value on a
range larger than one cell throws an exception. The question is still
valid for properties like .Interior.Color and .Locked .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top