VBA - call function without return variable

余生颓废 提交于 2020-05-29 06:42:46

问题


i have function:

Function importCSV(fileName As Variant) As Boolean

' some code
' no importCSV = TRUE

end Function

i call this function

importCSV (fileName As Variant)

every do OK, bud when a modific function.

Function importCSV(fileName As Variant, linkToHeader As Boolean) As Boolean
    ' some code
    ' no importCSV = TRUE

end Function

i cant call function like this

importCSV (fileName As Variant, TRUE)

VBA detect syntax error and a must call

a = importCSV(fileName As Variant, TRUE)

Why?


回答1:


To avoid assigning the return value to any variable you can use call keyword

call importCSV(fileName As Variant, TRUE)

Additionally you can call the function this way:

importCSV fileName:="File name", linkToHeader:=TRUE


来源:https://stackoverflow.com/questions/43228686/vba-call-function-without-return-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!