passing optional vba arguments to vba (dll) from vlisp...

passing optional vba arguments to vba (dll) from vlisp...

Anonymous
Not applicable
304 Views
1 Reply
Message 1 of 2

passing optional vba arguments to vba (dll) from vlisp...

Anonymous
Not applicable
hi

i was wondering if it was possible to pass optional vba arguments to vba
from vlisp...i've tried a few different ways (that i could think of) but
neither of them seem to work...

'vba (TestDLL.dll -> cTestClass)
public sub test (byval sMsg as string, byval sOptionalString as string = "",
optional bShowMessage as boolean = true)

if bShowMessage = true then
If not sOptionalString = "" then
msgbox sMsg & sOptionalString
else
msgbox sMsg
End if
end if

end sub

;lisp
(defun test (`sMsg `vOptionalList / `odCVariable `ReturnValue)
(setq `odCTest (vlax-create-object "TestDll.cTestClass"))
(vlax-invoke-method
`odCTest
'Test
`sMsg
(if (/= (cdr (assoc "OptionalString" `vOptionalList)) nil)
(cdr (assoc "OptionalString" `vOptionalList))
); doesn't work
;;; (if (/= (cdr (assoc "OptionalString" `vOptionalList)) nil)
;;; (strcat "sOptionalString := " (cdr (assoc "OptionalString"
`vOptionalList)))
;;; ); doesn't work
;;; (if (/= (cdr (assoc "OptionalString " `vOptionalList)) nil)
;;; (cdr (assoc "ShowMessage" `vOptionalList))
;;; ); doesn't work
;;; (if (/= (cdr (assoc "OptionalString " `vOptionalList)) nil)
;;; (strcat "bShowMessage := " (cdr (assoc "ShowMessage"
`vOptionalList)))
;;; ); doesn't work 'cause :vlax-false / true is not a string
)
(vlax-release-object `odCTest )
) ;test

;lisp calling function
(test
"This is a test"
(list
(cons "OptionalString" "blar blar blar optional")
(cons "ShowMessage" :vlax-true)
);list
)

any help would be great...

cheers

Mark
0 Likes
305 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Have a search in VLisp help and VBA help about the following functions.

VLisp - (vl-registry-write reg-key [val-name val-data])

VBA - GetSettings

The VB GetSettings retrieves from an area in the registry HKCU\Software\Microsoft\VB and VBA Program Settings\

Works fine for me when I want to share more than the peremitted 5 string variables.

John Bilton
0 Likes