0

Can anybody explain what are the round brackets do in this situation for errors and warrnings?
errors and warnings are Enum values passed by reference.
When I do not use the round brackets, I am getting a warning about an implicit conversion.

Dim errors As swFileSaveError_e
Dim warrnings As swFileSaveWarning_e
Me.ModelDoc.Extension.SaveAs3(fileName, swSaveAsVersion_e.swSaveAsCurrentVersion, swSaveAsOptions_e.swSaveAsOptions_Silent, Nothing, Nothing, (errors), (warnings))
Jimi
  • 29,621
  • 8
  • 43
  • 61
gegy
  • 87
  • 7
  • That you're passing the value ByRef, not the locals reference. Have you checked what is the value of `errors` and `warrnings` after the method call? Are the two last parameters declares as `ByRef SomeValue1 as Integer, ByRef SomeValue2 as Integer`? Have you checked what instead happens if you declare the two parameters as `ByRef SomeValue1 as swFileSaveError_e, ByRef SomeValue2 as swFileSaveWarning_e` and pass the local variable directly (no paretheses)? – Jimi Mar 04 '21 at 09:08
  • BTW, I assume `Option Strict On` will issue two errors, not two warnings, if you pass an Enum as argument when the method is expecting a ByRef Integer. – Jimi Mar 04 '21 at 09:18
  • 3
    The brackets evaluate the expression, which creates a temporary copy which is then passed byref. It is a way to not actually pass a variable byref when you don't want it changed. This behaviour was preserved [from VB6](https://stackoverflow.com/q/8070033/11683). – GSerg Mar 04 '21 at 09:23
  • The SaveAs3 Methode is provided by a third party api so i can't review the code of the api. – gegy Mar 04 '21 at 12:16
  • You don't have to do that in order to understand what the brackets do. – GSerg Mar 04 '21 at 13:01
  • It's not clear whether you just want to know what the parentheses are for, if you're the one one that used the parentheses to avoid the *warning* / exception, or if you actually want the method to set the values of the locals you have declared, which, by now, you're simply discarding, passing the value of an Enum local variable (will be `0` for both arguments) or you actually want the values returned `ByRef`: in this case, you should pass two local variables declared as `Integer` (to comply with parameters Type), then cast the value set to the Enumerators Type. – Jimi Mar 04 '21 at 13:19

0 Answers0