dpatfield66
Well-known member
- Joined
- Apr 6, 2006
- Messages
- 136
- Programming Experience
- 5-10
I can't remember if this is called overloading a method or some other name, but essentially you can have the same Method with different arguments:
Example:
------------------------------------------------------------
FormatName(ByVal lastName as String,ByVal middleName as String, ByVal firstName as String)
FullName = lastName & "," & firstName & " " & middleName
-----------------------------------------------------------
OR...
----------------------------------------------------------
FormatName(ByVal lastName as String,ByVal firstName as String)
FullName = lastName & "," & firstName
-----------------------------------------------------------
One handles all 3 names (first, last, middle) and the other only handles first and last name. Could someone explain how this is beneficial? I know it is, but I can't remember why. Why wouldn't I just call one:
FormatFirstLastName and the other FormatFullName, for example?
I'm missing something. Doesn't overloading (or whatever it's called) mean that I only have to write the function or Sub once?? And then the code knows what to do base on the arguments?
I'm doing this wrong I think. Becuase I'm writing the Sub twice, just like two different subs that might as well have diff names, right?
Help appreciated.
Example:
------------------------------------------------------------
FormatName(ByVal lastName as String,ByVal middleName as String, ByVal firstName as String)
FullName = lastName & "," & firstName & " " & middleName
-----------------------------------------------------------
OR...
----------------------------------------------------------
FormatName(ByVal lastName as String,ByVal firstName as String)
FullName = lastName & "," & firstName
-----------------------------------------------------------
One handles all 3 names (first, last, middle) and the other only handles first and last name. Could someone explain how this is beneficial? I know it is, but I can't remember why. Why wouldn't I just call one:
FormatFirstLastName and the other FormatFullName, for example?
I'm missing something. Doesn't overloading (or whatever it's called) mean that I only have to write the function or Sub once?? And then the code knows what to do base on the arguments?
I'm doing this wrong I think. Becuase I'm writing the Sub twice, just like two different subs that might as well have diff names, right?
Help appreciated.