Sometimes it is necessary to call a procedure with an optional argument. VB provides an opportunity to do so: https://msdn.microsoft.com/en-us/library/f25e2b6b.aspx. I created a little workaround which is not working in every case, for example not, when the optional parameter is at the last position of the argument list.
Call Example1(1,) 'throws an error message Call Example1(1) 'throws an error message Call Example2(1,,3) 'works ' Not working Sub Example1(param1, param2) If VarType(param2) = 10 Then param2 = 0 End Sub ' Working Sub Example2(param1, param2, param3) If VarType(param2) = 10 Then param2 = 0 End Sub
My idea is to introduce optional parameters for procedures in the argument list with the possibility to define a default value.
Sub Example1(param1, Optional ByVal param2 = 0)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello
Thank you for your request. We understand your suggestion but given that that just a few sponsors are supporting your entry and nearly no other customer asked this extension direct to us, we have decided to decline this suggestion. As script language we support VBS which is a subset of VB. With that we must respect the VBS restriction.
Greetings
Walter