ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Addpolyline function (https://www.excelbanter.com/excel-programming/382836-addpolyline-function.html)

equiangular

Addpolyline function
 
Hi,

I got some problems on addpolyline function


Sub test()

Dim a(1 To 4, 1 To 2) As Single
Dim i As Integer, j As Integer

For i = 1 To 4
a(i, 1) = i * 100
a(i, 2) = (i * i) * 100
Next i

ActiveSheet.Shapes.AddPolyline a

End Sub

I got runtime error 1004 if I changed the line "Dim a(1 To 4, 1 To 2) As
Single" to "Dim a(1 To 4, 1 To 2) As Variant". Is it a bug?

Juan Pablo González

Addpolyline function
 
And why do you want to have that array as Variant() ? When you create the
array as variant, the coordinates are dimmed as integer, which might be why
the AddPolyline code fails.

--
Regards,

Juan Pablo González

"equiangular" wrote in message
...
Hi,

I got some problems on addpolyline function


Sub test()

Dim a(1 To 4, 1 To 2) As Single
Dim i As Integer, j As Integer

For i = 1 To 4
a(i, 1) = i * 100
a(i, 2) = (i * i) * 100
Next i

ActiveSheet.Shapes.AddPolyline a

End Sub

I got runtime error 1004 if I changed the line "Dim a(1 To 4, 1 To 2) As
Single" to "Dim a(1 To 4, 1 To 2) As Variant". Is it a bug?




equiangular

Addpolyline function
 
How about if I use double?
The code also fails.
The main point is VB should be able to convert variable types on the fly
unless the conversion is not compatible

Juan Pablo González wrote:
And why do you want to have that array as Variant() ? When you create the
array as variant, the coordinates are dimmed as integer, which might be why
the AddPolyline code fails.



All times are GMT +1. The time now is 08:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com