Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AttributesInVBA] - Overloaded default procedure? #4

Closed
elie-g opened this issue Oct 23, 2019 · 3 comments
Closed

[AttributesInVBA] - Overloaded default procedure? #4

elie-g opened this issue Oct 23, 2019 · 3 comments
Assignees

Comments

@elie-g
Copy link

elie-g commented Oct 23, 2019

Is it possible to create an overloaded default procedure?

So you could do something like this:
------------ Class ------------

'...
Public Function DefaultProc() As Something
	Attribute '...
	'...
End Function

Public Function DefaultProc(ByVal myNumber As Integer) As Something
	Attribute '... ??
	'...
End Function

Public Function DefaultProc(ByVal myString As String) As Something
	Attribute '... ??
	'...
End Function
'...

------------ Main ------------

Dim Instance As New MyClass
Debug.Print Instance
Debug.Print Instance("Joe")
Debug.Print Instance(1)
@Vitosh
Copy link
Owner

Vitosh commented Oct 23, 2019

@DrunkenPoney - give it a try and write a few tests. If it works, I will add it to the project.

@elie-g
Copy link
Author

elie-g commented Oct 24, 2019

@Vitosh I tried it but I couldn't find any way to overload the default function/procedure. Though, I'm not an expert in VBA and there might be a way I don't know but a simple overload with the same procedure name but with different parameters does not work. I also tried to set the same VB_UserMemId attribute but it didn't work either.

@Vitosh
Copy link
Owner

Vitosh commented Dec 19, 2019

@DrunkenPoney - Joel Spolsky has some ideas here:
https://stackoverflow.com/questions/64436/function-overloading-and-udf-in-excel-vba
(The guy literally put VBA in Excel, so he is a good source :)

@Vitosh Vitosh closed this as completed Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants