0

I have overloaded a function 3 times.

I saw that VBA supports function overloading but i am unable to execute this without getting error.

Function nothingToZero(X As Integer) As Integer
    If X = "" Then
        nothingToZero = 0
    Else
        nothingToZero = X
    End If
End Function
    
Function nothingToZero(X As Single) As Integer
     If X = "" Then
         nothingToZero = 0
     Else
         nothingToZero = X
     End If
End Function
    
Function nothingToZero(X As String) As Integer
   If X = "" Then
       nothingToZero = 0
   Else
       nothingToZero = X
   End If
End Function
9
  • 2
    What's your source? VBA does not support function overloading. Commented Jun 25, 2020 at 14:33
  • stackoverflow.com/questions/64436/… Commented Jun 25, 2020 at 14:34
  • 2
    VBA isn't the same thing as VB.Net. Despite the similarity in syntax, the underlying semantics of the two languages are very different. Commented Jun 25, 2020 at 14:39
  • 1
    Microsoft in its wisdom has created an odd situation where two fairly different languages have a very similar name and furthermore a syntax which is so similar that it is easy to see code written in one language and mistake it for code written in the other. Google frequently calls up VB.Net solutions even when you use VBA in the search. Commented Jun 25, 2020 at 14:42
  • 1
    Ints and singles will never be "". They default to zero. Commented Jun 25, 2020 at 14:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.