mccad 老大:我在这请教你一个问题,和DLL相关的
Sub Line_Equation(ByRef LParam() As Double, ByVal p1 As Variant, ByVal p2 As Variant) LParam(0) = p2(1) - p1(1) LParam(1) = p1(0) - p2(0) LParam(2) = -1# * LParam(0) * p1(0) - LParam(1) * p1(1) End Sub
上面是VB代码,我生成DLL文件,然后在VIsual Lisp 中插入
代码如下
(setq dllfile (findfile "d:\\vb\\dll\\linecircle.dll")) (vlax-import-type-library :tlb-filename dllfile :methods-prefix "LCM-" :Properties-prefix "LCM-" :constants-prefix "LCM-" ) (setq lcobj (vlax-get-or-create-object "linecircle.calculate"))
(setq arr1 (vlax-make-safearray vlax-vbvariant '(0 . 1))) (vlax-safearray-fill arr1 '(1.0 1.0 )) (setq arr2 (vlax-make-safearray vlax-vbvariant '(0 . 1))) (vlax-safearray-fill arr2 '(2.0 3.0 )) (vlax-invoke-method lcobj "Line_Equation" 'line1 arr1 arr2)
错误如下:
error: Automation Error. 下标越界
其它在VB中没有用到ByRef 的可正常使用
请问是什么问题啊?怎么解决? |